You might try the following threadR30;
http://www.thescripts.com/forum/thread366510.html
/tr
From: helpwithvb
yahoogroups.com [mailto:helpwithvb
yahoogroups.com] On Behalf Of Tim Lewis
Sent: Monday, September 17, 2007
1:55 PM
To: helpwithvb
yahoogroups.com
Subject: [helpwithvb] WM_GETTEXT
I am trying to use WM_GETTEXT to capture the data in a
window. Instead of
the data in the window, I am getting the title of the window. Can someone
review my code and tell me where I am messing up? In my example, I have
Notepad open with stuff typed in like "dog", "cat". Instead
of getting
that, I am getting "Untitled - Notepad" as the result for strData.
Thank you,
Tim
Option Explicit
Public 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 Declare Function FindWindow Lib "user32" Alias
"FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public 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
Public Const WM_GETTEXTLENGTH = &HE
Public Const WM_GETTEXT = &HD
Public Const WM_SETTEXT = &HC
Sub CaptureWindow()
Dim lngHandle As Long, lgnDataLength As Long, lngResult As Long
Dim strData As String, strWindow As String
strWindow = "Untitled - Notepad"
lngHandle = FindWindow(vbNullString, strWindow)
If lngHandle <> 0 Then
lgnDataLength = SendMessage(lngHandle, WM_GETTEXTLENGTH, ByVal 0,
ByVal 0) + 1
strData = Space(lgnDataLength - 1)
lngResult = SendMessage(lngHandle, WM_GETTEXT, ByVal lgnDataLength,
ByVal strData)
End If
MsgBox strData
End Sub