|
-
Nov 23rd, 2001, 11:03 AM
#1
Thread Starter
Hyperactive Member
Active Window
If I press a command button (Command1), I want a message box for EVERY program (other then mine) I click on to display that program's caption. How can I do this? Any help would be GREATLY appreciated. Thanks in advance. Later,
-zer0 flaw
-
Nov 24th, 2001, 02:11 AM
#2
Conquistador
<¿>
?
VB Code:
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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
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 Type POINTAPI
x As Long
y As Long
End Type
Dim textlen As Long ' receives length of text of the window
Dim wintext As String ' receives the text of the window
Dim slength As Long ' receives the length of the returned string
Dim myhWnd As Long
Dim mousePos As POINTAPI
Private Sub Timer1_Timer()
' Every 10 seconds get the title of the window which the cursor is over
' Find out how many characters are in the window's text.
' Add 1 to compensate for the terminating null.
retval = GetCursorPos(mousePos)
myhWnd = WindowFromPoint(mousePos.x, mousePos.y)
Debug.Print myhWnd
textlen = GetWindowTextLength(myhWnd) + 1
' Make sufficient room in the buffer.
wintext = Space(textlen)
' Retrieve the text of window Form1.
slength = GetWindowText(myhWnd, wintext, textlen)
' Remove the empty space from the string, if any.
Text1.Text = Text1 & vbCrLf & Left(wintext, slength)
' Display the result.
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
|