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
Printable View
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
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
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...