What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » hWnd of IMWindowClass chat input box

Pages: (2): « First [ 1 ] 2 » Last »
2 votes - 5 average   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
Profile E-Mail PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
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
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: hWnd of IMWindowClass chat input box
To find the hWnd of the textbox you will need to use ActiveAccessibility. Note that it isn't all that stable in VB Dempsey and I have found.

Matty's reply to Active Accessibility for incoming messages
10-10-2005 04:28 PM
Profile E-Mail PM Find Quote Report
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
Profile E-Mail PM Find Quote Report
Stigmata
Veteran Member
*****



Posts: 3520
Reputation: 45
21 / Other / Flag
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
Profile PM Web Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: hWnd of IMWindowClass chat input box
Interesting code Matty, that may be really usefull!(Y)

eSould, take a look at this thread;)
10-10-2005 04:58 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
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
Profile E-Mail PM Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
32 / Male / Flag
Joined: Mar 2003
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! :O
YouTube closed-captions ripper (also allows you to download videos!)
10-10-2005 05:14 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
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! :O

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
Profile E-Mail PM Find Quote Report
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
35 / Male / –
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
Profile PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On