'Get handle of the window at mouse cursor position using WindowFromPoint API
'Get handle of the window at mouse cursor position using WindowFromPoint API
API Declarations
x As Long
y As Long
End Type
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Rate 'Get handle of the window at mouse cursor position using WindowFromPoint API
(1(1 Vote))
'http://www.geocities.com/marskarthik
'http://marskarthik.virtualave.net
'Email: [email protected]
Private Sub Form_Load()
'Set window on top of all
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 1
Timer1.Enabled = True
Timer1.Interval = 10
End Sub
'Note: This program is very useful to developing spy programs
Private Sub Timer1_Timer()
Dim cname As String
Dim cp As POINTAPI
Dim rval As Long
Dim hwnd As Long
'Get current Cursor Position
rval = GetCursorPos(cp)
'Get the handle of the window at mouse cursor point
hwnd = WindowFromPoint(cp.x, cp.y)
cname = Space(128)
'Get Classname
rval = GetClassName(hwnd, cname, 128)
Form1.Caption = Left(cname, InStr(cname, Chr(0)) - 1)
Label1.Caption = "Classname = " & Left(cname, InStr(cname, Chr(0)) - 1) & _
Chr(13) & " Handle = " & hwnd
End Sub
'Get handle of the window at mouse cursor position using WindowFromPoint API Comments
No comments yet — be the first to post one!
Post a Comment