Private Declare Function WindowFromPoint Lib "user32.dll" _
(ByVal xPoint As Long, ByVal yPoint As Long) As Long Private Declare Function SendMessage Lib "user32.dll" _ Alias "SendMessageA" (ByVal hWnd As Long, _ ByVal Msg As Long, wParam As Any, lParam As Any) As Long Private Declare Function GetCursorPos Lib "user32.dll" _ (lpPoint As POINT_TYPE) As Long Private Type POINT_TYPE x As Long y As Long End Type Private Const WM_GETTEXT = &HD Private Const TXT_LEN = 100 Private Sub Timer1_Timer() Dim ppoint As POINT_TYPE Dim ttxt As String ttxt = Space(100) 'Give space For window text errval = GetCursorPos(ppoint) 'Get Cursor Point thwnd = WindowFromPoint(ppoint.x, ppoint.y) 'Get window handle of window under cursor errval = SendMessage(thwnd, WM_GETTEXT, ByVal TXT_LEN, _ ByVal ttxt) 'Get text of that window ttxt = RTrim(ttxt) 'Remove Spaces Text1.Text = ttxt 'Display results End Sub |