|
-
Mar 7th, 2001, 09:34 AM
#1
Thread Starter
New Member
hi , im trying to obtain text from msn messenger window
thats bacically it
if any one could help i would be very chuffed
cheers
ali
-
Mar 7th, 2001, 05:03 PM
#2
Frenzied Member
You need the handle of the window whose text you want to get. After thet use the GetWindowText and GetWindowText API's.
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 SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Sub Form_Activate()
Dim MyStr As String
'Create a buffer
MyStr = String(100, Chr$(0))
'Get the windowtext
GetWindowText hwnd, MyStr, 100
'strip the rest of buffer
MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1)
End Sub
-
Mar 8th, 2001, 08:13 PM
#3
That works, but if the text you are getting is more than 100 bytes you are asking for a system crash.
You need to preallocate the size of the buffer to at least as big as you know the text is.
Code Sampe:
Length& = SendMessage(windowhandle&, WM_GETTEXTLENGTH, 0&, 0&)
buffer$ = String(Length&, 0&)
Make sure you include all constants in your module...
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
|