- Home
·
- Miscellaneous
·
- Function that takes a window name and control name as a parameter and returns the text in the speci
Function that takes a window name and control name as a parameter and returns the text in the speci
Function that takes a window name and control name as a parameter and returns the text in the specified control.
API Declarations
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Rate Function that takes a window name and control name as a parameter and returns the text in the speci
(1(1 Vote))
Dim WindowHandle As Long
Dim ControlHandle As Long
Dim TheText As String
Dim TheTextLen As Long
Dim ret As Long
GetTheText = "An Error Has Occured"
WindowHandle = FindWindow(vbNullString, TheWindowName)
If WindowHandle = 0 Then Exit Function
ControlHandle = FindWindowEx(WindowHandle, 0, vbNullString, TheControlName)
If ControlHandle = 0 Then Exit Function
TheTextLen = SendMessage(ControlHandle, WM_GETTEXTLENGTH, ByVal CLng(0), ByVal CLng(0)) + 1
TheText = Space(TheTextLen)
ret = SendMessage(ControlHandle, WM_GETTEXT, ByVal TheTextLen, ByVal TheText)
TheText = Left(TheText, ret)
GetTheText = TheText
End Function
Function that takes a window name and control name as a parameter and returns the text in the speci Comments
No comments yet — be the first to post one!
Post a Comment