Evo.
Code:
'**************************************
' Name: ***UPDATED*** Window SPY
' Description:***UPDATED*** Gets tons of
' information on the window your mouse is
' over.
' By: Matt Evans
'
'This code is copyrighted and has' limited warranties.Please see http://w
' ww.Planet-Source-Code.com/vb/scripts/Sho
' wCode.asp?txtCodeId=1424&lngWId=1'for details.'**************************************
'Put this is notepad and rename is winsp
' y.frm
Private Sub Timer1_Timer()
WindowSPY Text1, Text2, Text3, Text4, Text5, Text6, Text7, Text8, Text9
End Sub
Code:
'**** Put this In a module ****
'**************************************
'Windows API/Global Declarations for :**
' *UPDATED*** Window SPY
'**************************************
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Public Declare Function WindowFromPointXY Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Public Declare Function GetClassName& Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long)
Public Declare Function GetWindowWord Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As Integer
Public Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Function WindowSPY(WinHdl As TextBox, WinClass As TextBox, WinTxt As TextBox, WinStyle As TextBox, WinIDNum As TextBox, WinPHandle As TextBox, WinPText As TextBox, WinPClass As TextBox, WinModule As TextBox)
'Call This In A Timer
Dim pt32 As POINTAPI, ptx As Long, pty As Long, sWindowText As String * 100
Dim sClassName As String * 100, hWndOver As Long, hWndParent As Long
Dim sParentClassName As String * 100, wID As Long, lWindowStyle As Long
Dim hInstance As Long, sParentWindowText As String * 100
Dim sModuleFileName As String * 100, r As Long
Static hWndLast As Long
Call GetCursorPos(pt32)
ptx = pt32.X
pty = pt32.Y
hWndOver = WindowFromPointXY(ptx, pty)
If hWndOver <> hWndLast Then
hWndLast = hWndOver
WinHdl.Text = "Window Handle: " & hWndOver
r = GetWindowText(hWndOver, sWindowText, 100)
WinTxt.Text = "Window Text: " & Left(sWindowText, r)
r = GetClassName(hWndOver, sClassName, 100)
WinClass.Text = "Window Class Name: " & Left(sClassName, r)
lWindowStyle = GetWindowLong(hWndOver, GWL_STYLE)
WinStyle.Text = "Window Style: " & lWindowStyle
hWndParent = GetParent(hWndOver)
If hWndParent <> 0 Then
wID = GetWindowWord(hWndOver, GWW_ID)
WinIDNum.Text = "Window ID Number: " & wID
WinPHandle.Text = "Parent Window Handle: " & hWndParent
r = GetWindowText(hWndParent, sParentWindowText, 100)
WinPText.Text = "Parent Window Text: " & Left(sParentWindowText, r)
r = GetClassName(hWndParent, sParentClassName, 100)
WinPClass.Text = "Parent Window Class Name: " & Left(sParentClassName, r)
Else
WinIDNum.Text = "Window ID Number: N/A"
WinPHandle.Text = "Parent Window Handle: N/A"
WinPText.Text = "Parent Window Text : N/A"
WinPClass.Text = "Parent Window Class Name: N/A"
End If
hInstance = GetWindowWord(hWndOver, GWW_HINSTANCE)
r = GetModuleFileName(hInstance, sModuleFileName, 100)
WinModule.Text = "Module: " & Left(sModuleFileName, r)
End If
End Function
'****** End OF MODULE ******
rgdrajko