Jump to content

Questions about ControlSend


Recommended Posts

Im trying to send only a simple "V" to MU Online but always send in window that was active in the moment... Is controlsend ... send to background windows or inactive?

Im trying this

HotKeySet("{PAUSE}","Teste")
while 1
    Sleep(1000)
WEnd
Opt("WinTitleMatchMode",1)
Func Teste()
    Opt("WinTitleMatchMode",1)
    ;Run("Notepad.exe")
    WinActivate("MU", "")
    ;ControlGetFocus("Documento - WordPad", "")
    ;ControlSend("Untitled - Notepad",15,")
    ControlSend("MU", "", "","v")
    Exit
EndFunc
Link to comment
Share on other sites

Im trying to send only a simple "V" to MU Online but always send in window that was active in the moment... Is controlsend ... send to background windows or inactive?

Im trying this

HotKeySet("{PAUSE}","Teste")
while 1
    Sleep(1000)
WEnd
Opt("WinTitleMatchMode",1)
Func Teste()
    Opt("WinTitleMatchMode",1)
    ;Run("Notepad.exe")
    WinActivate("MU", "")
    ;ControlGetFocus("Documento - WordPad", "")
    ;ControlSend("Untitled - Notepad",15,")
    ControlSend("MU", "", "","v")
    Exit
EndFunc
In most cases, ControlSend will send to a control on a window, regardless of that windows status or whether or not it is active. The thing to remember is that ControlSend is meant to send a keystroke to a control, not just a window. It can work sometimes, but not always. It will be more reliable if you are able to specify a ContolID/ClassNameNN, (for example, in notepad it is "Edit1") but in some cases these are not available. Even with the ControlID, it may not work if the application is not using standard windows controls.

A question; is MU online a game that you play through a browser? (I ask out of ignorance, I have never heard of this game before). If it is, you may be able to use the _IE() functions to interact with it. Don't ask me how, I have never used them.

Also, ControlSend works differently in the latest (3.2.2.0) version of AutoIt than it did in previous versions, so if you are unable to get the desired results with the latest stable release, try an older version of AutoIT. It is going to be changed again in the next release so that it will be closer to how it was before.

Edited by improbability_paradox
Link to comment
Share on other sites

With respect to ControlSend() to an empty control parameter... ""

In 3.2.2.0 AutoIt sends a global keystroke.. It is a change from previous versions...

In 3.2.3.0 It will PostMessage to the window provided... in your case "MU".

Stay tuned for 3.2.3.0 or use a previous AutoIt version where the behavior was as you desire.

Thanks for clarifying!

@OP; Also, be aware that some games implement countermeasures to prevent you from sending keystrokes this way

Edit: Use the AutoIT Window Info tool (comes with AutoIT) to get the ControlID/ClassNameNN

Edited by improbability_paradox
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...