List Info

Thread: WM_GETTEXT




WM_GETTEXT
country flaguser name
United States
2007-09-17 12:55:17

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

__._,_.___
.

__,_._,___
RE: WM_GETTEXT
country flaguser name
United States
2007-09-17 13:36:53

You might try the following threadR30;

 

http://www.thescripts.com/forum/thread366510.html

 

/tr

 

 


From: helpwithvbyahoogroups.com [mailto:helpwithvbyahoogroups.com] On Behalf Of Tim Lewis
Sent: Monday, September 17, 2007 1:55 PM
To: helpwithvbyahoogroups.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&quot;, "cat&quot;. Instead of getting
that, I am getting "Untitled - Notepad&quot; as the result for strData.

Thank you,
Tim

Option Explicit

Public Declare Function SendMessage Lib "user32" Alias &quot;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 &quot;FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Public Declare Function FindWindowEx Lib "user32" Alias &quot;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&quot;
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

__._,_.___
Recent Activity
Visit Your Group
Ads on Yahoo!

Learn more now.

Reach customers

searching for you.

Y! Messenger

PC-to-PC calls

Call your friends

worldwide - free!

Yoga Resources

on Yahoo! Groups

Take the stress

out of your life.

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )