Sign in to follow this  
Followers 0
Iznobad

Sending same keyclick to multiple windows? [SOLVED]

10 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



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

8)


NEWHeader1.png

Share this post


Link to post
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)

}

}

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
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...

Share this post


Link to post
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?

Share this post


Link to post
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!

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  
Followers 0