Jump to content

Sending same keyclick to multiple windows? [SOLVED]


Iznobad
 Share

Recommended Posts

Hey Autoit'ers,

I've been using the wow-related script at http://www.autoitscript.com/forum/index.php?showtopic=13749 to send "F12" repeatedly to my World of Warcraft client

Now I've graduated to run 5 accounts of wow at once on the same computer and can only get it to send the "F12" to the active window.

The real question is then: How do I send the same keyclick to 5 windows that have the same window title? Even if they're in the background...?

I can rename the exe files, if that helps. If I can just get help on how to loop through the windows, i can probably figure out the clicking myself

I've tried the search but had no luck, maybe i was using the wrong search terms.

Regards,

Iz

EDIT: Solved. check my last post

Edited by Iznobad
Link to comment
Share on other sites

Just use send Alt+Tab and move to the next window

Thanks, I see what you mean, but it's not as easy as that. You see, I'm actively playing in one of the windows and the others should remain in the background. ALT-TAB'ing every second to a new window would seriously confuse me :)

I guess i need something like this (pseudo);

every 1 second {

For (every window called "World of Warcraft") {

Send key "F12" (even if in the background)

}

}

Link to comment
Share on other sites

I think I found a way to find my 5 windows.

In such an unlikely place as the autoit help file */me feels noobish*

WinList ( ["title" [, "text"]] )

gives a list of windows that match my title. follow up by a for loop,...

The only thing missing is now a way to send keys to background window. any ideas?

Edit: looks like controlSend is the thing.. only trouble is will it work on multiple same-named windows.... only one way to find out :)

Edited by Iznobad
Link to comment
Share on other sites

Edit: looks like controlSend is the thing.. only trouble is will it work on multiple same-named windows.... only one way to find out :)

ControlSend worked on the most-recently-active window with the right title. it di not send to all my open notepads

Link to comment
Share on other sites

ControlSend worked on the most-recently-active window with the right title. it di not send to all my open notepads

I've solved it. It turns out ControlSend accepts a window handle instead of a title :)

After that it was a simple matter to loop throught the winList and send keys.

her's my notepad experiment. it will send to any open notepad windows

$var = WinList("[CLASS:Notepad]")

For $i = 1 to $var[0][0]
; Only display visble windows that have a title
  $title = $var[$i][0]
  $handle = $var[$i][1] 
  If $title <> "" AND IsVisible($handle) Then
    MsgBox(0, "Details", "Title=" & $title & @LF & "Handle=" & $handle)
    $controlid = "[CLASS:Edit; INSTANCE:1]"
    ControlSend($handle,"",$controlid ,"text to send")
    
  EndIf
Next

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf

EndFunc

Now I'll just adapt it to my game. I think my @controlid will need to be changed.

Edited by Iznobad
Link to comment
Share on other sites

Hi, i'm sorry, but i couldn't help but gain some interest from what you are doing. Can you please explain how you have achieved to send something to each window without ALT-TABbing through each one...

Yes, of course.

Tak a look at my code above again.

the WinList call at the start assigns an array of window handles to my variable $var

Then i loop through that array and do some key sending to each window. The ControlSend function does not care whether your windows are active or not.

Your best bet for understanding is to open up 2-3 notepad windows and runs my script

Did that help?

Link to comment
Share on other sites

Yes, of course.

Tak a look at my code above again.

the WinList call at the start assigns an array of window handles to my variable $var

Then i loop through that array and do some key sending to each window. The ControlSend function does not care whether your windows are active or not.

Your best bet for understanding is to open up 2-3 notepad windows and runs my script

Did that help?

gee, thanks alot!

Link to comment
Share on other sites

gee, thanks alot!

You're welcome :)

Meanwhile i managed to get it to work on wow.

Here is my final solution that sends a {SPACE} to every World of Warcraft window, even if they're in the background or minimized:

$timeMin = 957
$timeMax = 2619
$key = "{SPACE}"

;get a list if window handles that match the text
$winList = WinList("World of Warcraft")

;run until killed/paused in the notification area
While 1 
   ;loop through the windows
   For $i = 1 to $winList[0][0]

      $title = $winList[$i][0]
      $handle = $winList[$i][1] 
      $controlid = ""
      $text = ""
      ControlSend($handle,$text,$controlid,$key)
      
     ;take a break to seem less like a macro
      $sleepTime = Random($timeMin, $timeMax)
         Sleep($sleepTime)
   Next
WEnd
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...