|
-
Dec 17th, 2000, 02:26 AM
#1
Thread Starter
Lively Member
Does anyone know of a code which specifically captures the active window of the desktop ?
-
Dec 17th, 2000, 03:40 AM
#2
This code will tell you the title of the Active Window.
Code:
Private Declare Function GetForegroundWindow _
Lib "user32" () As Long
Private Declare Function GetWindowTextLength Lib "user32" _
Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString _
As String, ByVal cch As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd _
As Long) As Long
Private Function GetActiveWindowTitle(ByVal ReturnParent As Boolean) As String
Dim i As Long
Dim j As Long
i = GetForegroundWindow
If ReturnParent Then
Do While i <> 0
j = i
i = GetParent(i)
Loop
i = j
End If
GetActiveWindowTitle = GetWindowTitle(i)
End Function
Private Function GetWindowTitle(ByVal hwnd As Long) As String
Dim l As Long
Dim s As String
l = GetWindowTextLength(hwnd)
s = Space(l + 1)
GetWindowText hwnd, s, l + 1
GetWindowTitle = Left$(s, l)
End Function
-
Dec 17th, 2000, 11:38 AM
#3
PowerPoster
how abt tis?
Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SNAPSHOT = &H2C
Private Const VK_MENU = &H12
Private Sub Command1_Click()
'Capture the Active Window
keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
'Load Image into the PictureBox
Picture1.Picture = Clipboard.GetData()
'Save new image file
SavePicture Picture1, "C:\picture1.bmp"
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|