I would like to be able to detect a word that my mouse cursor is on. I do not need it to work within my own program but be able to determine text in another program.
Can anyone help with this.
I am using VB4.0 /32
Joseph
Printable View
I would like to be able to detect a word that my mouse cursor is on. I do not need it to work within my own program but be able to determine text in another program.
Can anyone help with this.
I am using VB4.0 /32
Joseph
just make clear that ..... u want text from within ur programm or u want text from someother programme into ur programme,,,, so i can think furthor on it,,,,
Thanks for the reply.
I would like text from some other program that I can manipulate in my own program.
Thanks again.
Joseph
You mean, get all other text that the mouse is over?
Code:Needed: Form, Module, Textbox, Timer
Type POINTAPI 'Declare types
X As Long
Y As Long
End Type
Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) 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
Public Declare Function WindowFromPointXY Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Function GetCaption(hWnd)
hwndLength% = GetWindowTextLength(hWnd)
hwndTitle$ = String$(hwndLength%, 0)
a% = GetWindowText(hWnd, hwndTitle$, (hwndLength% + 1))
GetCaption = hwndTitle$
End Function
Private Sub Timer1_Timer()
Dim pnt As POINTAPI
GetCursorPos pnt
yhwnd% = WindowFromPointXY(pnt.X, pnt.Y)
Text1.text = GetCaption(yhwnd%)
End Sub
Thanks for that. But it wasn't exactly what I needed. I need something that will recognize the word that the mouse is on..In a Window. Such as the main window in a terminal app.
Thanks
Joseph E