hWnd of IMWindowClass chat input box |
Author: |
Message: |
eSouL
Junior Member
Posts: 36
Joined: Oct 2005
|
O.P. hWnd of IMWindowClass chat input box
Hi,
I'm using VB. How do I get the hwnd of the text box where user inputs his chat messages? Second question:
What is the RegisterWindowMessage of MSN to send a chat message? And what is the hwnd to which the SendMessage function sends?
|
|
10-10-2005 03:32 PM |
|
|
J-Thread
Full Member
Posts: 467 Reputation: 8
– / / –
Joined: Jul 2004
|
RE: hWnd of IMWindowClass chat input box
2nd question: There is no RegisterWindowMessage for sending chat messages with msn. You have to send the chars to the input box and end with a Return, so the text is send. There has been a discussion about this lately, just search on the forums.
|
|
10-10-2005 04:19 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
|
10-10-2005 04:28 PM |
|
|
eSouL
Junior Member
Posts: 36
Joined: Oct 2005
|
O.P. RE: hWnd of IMWindowClass chat input box
Matty, is there a method to set the text of the textbox or perhaps sendkeys to it?
|
|
10-10-2005 04:39 PM |
|
|
Stigmata
Veteran Member
Posts: 3520 Reputation: 45
21 / /
Joined: Jul 2003
|
RE: hWnd of IMWindowClass chat input box
quote: Originally posted by eSouL
is there a method to set the text of the textbox
yep, using active accessibility
|
|
10-10-2005 04:57 PM |
|
|
J-Thread
Full Member
Posts: 467 Reputation: 8
– / / –
Joined: Jul 2004
|
RE: hWnd of IMWindowClass chat input box
Interesting code Matty, that may be really usefull!
eSould, take a look at this thread
|
|
10-10-2005 04:58 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: hWnd of IMWindowClass chat input box
quote: Originally posted by Stigmata
quote: Originally posted by eSouL
is there a method to set the text of the textbox
yep, using active accessibility
http://forums.msnfanatic.com/index.php?showtopic=11778
quote: Originally posted by eSouL
Matty, is there a method to set the text of the textbox or perhaps sendkeys to it?
In a Module
code: 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 Declare Function GetForegroundWindow Lib "user32" () As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) _
As Long
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) _
As Long
Public Const WM_CHAR = &H102
Public Const VK_RETURN = &HD
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const INFINITE = &HFFFF
Public lngPrevWnd As Long
Public ConversationWnd_Obj As Object
Public Sub SendText(hwnd As Long, _
sText As String, _
Optional bSend As Boolean = False, _
Optional bKeepFocus As Boolean = True)
Dim RetVal As Long
RetVal = SetForegroundWindow(hwnd)
WaitForSingleObject RetVal, INFINITE
For i = 1 To Len(sText)
Call PostMessage(hwnd, WM_CHAR, Asc(Mid(sText, i, 1)), 0)
Next i
If bSend Then
Call PostMessage(hwnd, WM_KEYDOWN, VK_RETURN, 0&)
Call PostMessage(hwnd, WM_KEYUP, VK_RETURN, 0&)
End If
If Not bKeepFocus Then
Call SetForegroundWindow(lngPrevWnd)
End If
End Sub
In your Class Module
code: Public Function ParseCommand(ByVal sCommand As String, _
ByVal sCommandArg As String, _
ByVal oConversationWnd As Object, _
ByRef sResult As String) _
As Boolean
Set ConversationWnd_Obj = oConversationWnd
Select Case LCase(sCommand)
Case Is = "/xtest"
lngPrevWnd = GetForegoundWindow()
SendText FindWindowEx(ConversationWnd_Obj.hWnd, _
0&, _
"DirectUIHWND", _
vbNullString), _
"this text will be sent", _
True, _
True
sResult = ""
ParseCommand = True
Exit Function
End Select
ParseCommand = False
End Function
This post was edited on 10-10-2005 at 11:24 PM by matty.
|
|
10-10-2005 05:11 PM |
|
|
Mike
Elite Member
Meet the Spam Family!
Posts: 2795 Reputation: 48
32 / /
Joined: Mar 2003
Status: Online
|
RE: hWnd of IMWindowClass chat input box
So, using AA, you can get a hWnd to the send text box, and do stuff with it? (like type a message just like at your example)
I didn't know it!
|
|
10-10-2005 05:14 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: hWnd of IMWindowClass chat input box
quote: Originally posted by Mike
So, using AA, you can get a hWnd to the send text box, and do stuff with it? (like type a message just like at your example)
I didn't know it!
Yes using AA you can do that, but not with example I have. The axample I have just reads the text and displays the parent windows hWnd not the textbox one. Now I am not sure if the hWnd passed through is the textbox or the DirectUIHWND. But the code I posted will actually put text in the window not using AA.
The link to msnfanatic forums is from TheHuuf who posted sending text using AA.
|
|
10-10-2005 05:17 PM |
|
|
Plik
Veteran Member
Posts: 1489 Reputation: 46
35 / / –
Joined: Jun 2004
|
RE: hWnd of IMWindowClass chat input box
quote: Originally posted by Matty
code: Public Declare Function GetForegroundWindow Lib "user32" () As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) _
As Long
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) _
As Long
Public Const WM_CHAR = &H102
Public Const VK_RETURN = &HD
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const INFINITE = &HFFFF
Public lngPrevWnd As Long
Public ConversationWnd_Obj As Object
Public Sub SendText(hwnd As Long, _
sText As String, _
Optional bSend As Boolean = False, _
Optional bKeepFocus As Boolean = True)
Dim RetVal As Long
RetVal = SetForegroundWindow(hwnd)
WaitForSingleObject RetVal, INFINITE
For i = 1 To Len(sText)
Call PostMessage(hwnd, WM_CHAR, Asc(Mid(sText, i, 1)), 0)
Next i
If bSend Then
Call PostMessage(hwnd, WM_KEYDOWN, VK_RETURN, 0&)
Call PostMessage(hwnd, WM_KEYUP, VK_RETURN, 0&)
End If
If Not bKeepFocus Then
Call SetForegroundWindow(lngPrevWnd)
End If
End Sub
IIRC, It isnt neccessary to set the windows focus to use post message to send keys.
|
|
10-10-2005 05:36 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|