Using control send on windows live messenger For auto typing text

4k Views Asked by At

Hi i want to make a sort of a bot for WLM, But the normal controlsend in autoit wont work

the basic question is how can i send a text to the windows live messenger window Without activating it?

Example: There is someone in WLM with the window active called "Joop" I do:

ControlClick("Joop","","[CLASS:DirectUIHWND; INSTANCE:2]","Left",1,322,507)
ControlSend("Joop","","[CLASS:DirectUIHWND; INSTANCE:2]","Hi Joop")  

this doesn't work however when I do this

WinActivate("Joop","")
ControlClick("Joop","","[CLASS:DirectUIHWND;INSTANCE:2]","Left",1,322,507)
ControlSend("Joop","","[CLASS:DirectUIHWND; INSTANCE:2]","Hi Joop")  

it does work however now its activated what i dont want. there is a problem with the window the whole msn talk window is one window so no extra control to type in thats why i tried the contolClick on the coordinates of the typing screen without succ6

this is the summary.

Text:   
Position:   0, 28
Size:   882, 607
ControlClick Coords:    282, 180
Style:  0x56000000
ExStyle:    0x00010000
Handle: 0x00190916

>>>> Mouse <<<<
Position:   1885, 557
Cursor ID:  0
Color:  0xFFFFFF

>>>> StatusBar <<<<

>>>> Visible Text <<<<


>>>> Hidden Text <<<<
CVoiceVideoAvatarHostWindow

does anyone know how to get something in that textfield without activating it (so it can run on background) and using a lame function like send.

OR how can i send a text to the windows live messenger window Without activating it

Thanks Matthy

3

There are 3 best solutions below

0
On

MSN is purposefully resisting automation. It's not a limitation of the Windows API. If your goal is to automate a MSN chat, you can do so either by directly sending the TCP packets, or by automating another application which supports MSN (Digsby, Pidgin, etc.) and which works better with automation.

By directly sending the TCP packets you are writing your own program, from scratch, which to the outside world behaves just as MSN. There are user-made documentation about the protocol. One that I have used in the past is here: http://www.hypothetic.org/docs/msn/notification/authentication.php but I am entirely unsure whether it is still up-to-date. If you are familiar with networking, TCP, packet capturing and replaying, then I do suggest going this route as it's the most stable, long-term approach. (And I think: The most fun.)

However, not all projects demand a stable and long-term approach. It seems to me like you were just messing with automating some of the applications you happened to have on your computer, and MSN is of course one of the more interesting ones. Microsoft decided that when they built the MSN client it should not be made easy for anyone to try and automate the application. I think this was mostly done to prevent spam. In the early days it worked, because other people hadn't yet publically documented the protocol. And thus anyone who wanted to spam now had to make a costly investment.

If you do decide to continue with automating the official MSN client, or any other application that resists automation, there are a few tricks that you can try:

  • ControlSend without specifying the control parameter (use empty string "")
  • ControlClick on the window with specifying coordinates with using empty string for control parameter again
  • Eventually, simply Send/MouseClick with optional BlockInput

There are a lot more combinations that you can try (especially ControlX functions) that sometimes miraculously will work, but remember that in the end they are all just window messages. You can do everything in automation with the _SendMessage function, provided you know what you're doing.

0
On

Ok, maybe finally an answer... at least this test app I coded works as following:

Somewhere in the beginning of your script you have to set the state of your WLM to @SW_HIDE. Later when you try to do ControlXxxx-stuff you first set a variable on your active window. Now you can optionally block your input and activate your hidden window. It now works as you described above and afterwards you reactivate your last active window. Optionally undo the input block again.

That should solve your question with the least breaktime... you could play with your Mouse Cursor Style in the meantime to simulate some CPU load, so the block input is not too offending. But the action is so fast you won't even recognise it... (maybe it will swallow some keypresses though)

Give it a try!

Opt("WinTitleMatchMode", 2)

#include <GuiConstantsEx.au3>
$GUI = GUICreate("Beispiel HiddenApp", 392, 323)
$ed = GUICtrlCreateEdit("nix", 1, 1, 390, 321)
GUISetState()

Sleep(1000)

GUISetState(@SW_HIDE, $GUI)
WinActivate("SciTE")
Sleep(1000)

BlockInput(1)
$act = WinActive("[ACTIVE]")
WinActivate($GUI)
ControlClick($GUI, "", $ed, "primary", 1, 50, 50)
ControlSend($GUI, "", $ed, "before{Alt}{Tab}after")
WinActivate($act)
BlockInput(0)

Sleep(1000)

GUISetState(@SW_SHOW, $GUI)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            ;;;
    EndSwitch
WEnd
0
On

Certain designs and interfaces make it very difficult, if not virtually impossible, for AutoIt to tap into the interface to read control information. I would suggest either using the WLM protocol manually via your own client, or utilize a client that doesn't make screen grabbing the text hard or impossible.