Jump to content

Switching between two of the same windows


Recommended Posts

I'm trying to switch between two windows with the same name with multiple others windows open.

I've tried using alt tab but it only cycles through two of the open windows. It works if those two windows are the ones I want to cycle through but otherwise it goes into an infinite loop.

Guys have any ideas?

Link to comment
Share on other sites

  • Moderators

I'm trying to switch between two windows with the same name with multiple others windows open.

I've tried using alt tab but it only cycles through two of the open windows. It works if those two windows are the ones I want to cycle through but otherwise it goes into an infinite loop.

Guys have any ideas?

Check out WinGetHandle().... handles are unique unlike the titles.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

This greatly helped me identify the windows, but I still cannot figure out how to cycle between more than two windows checking which one is the one I wish to cycle to.

Could you give an outline what these two windows would have different that you know it's the one you want or better yet, could you supply the code that is failing?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Could you give an outline what these two windows would have different that you know it's the one you want or better yet, could you supply the code that is failing?

Situation A) Only two windows are open, they both have the same title but different handles. So I check if I'm already at the window I wish to move to with an if statement (checking between what the handle is supposed to be and what it actually is). If the statement is true it returns false(saying that I havn't changed windows) and if its false it sends !TAB(Alt+Tab) checks again .If its false it sends !TAB again and again till it is. This works

Situation B)The two same windows are open, except with another window with an opposite title. Dosent Work because !TAB only switched between two of the three windows.

Func changeToBlack()

WinActivate("Title")

$black=0x001000E4

$white=0x000E0110

$CurrentWindow= WinGetHandle("Title")

If $CurrentWindow=$black Then

return False

Else

While Not $CurrentWindow=$black

Send("!{TAB}")

WEnd

Return True

EndIf

EndFunc

Edited by aswfreak29
Link to comment
Share on other sites

  • Moderators

I see... Look at WinActivate()

If WinActive(WinGetHandle("")) <> $black Then WinActivate($black)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I see... Look at WinActivate()

If WinActive(WinGetHandle("")) <> $black Then WinActivate($black)

Could you explain that code a little bit more, my only previous knowledge is java that looks like spanish.The <> and "" mainly.

Edited by aswfreak29
Link to comment
Share on other sites

  • Moderators

Could you explain that code a little bit more, my only previous knowledge is java that looks like spanish.The <> and "" mainly.

<> is less than or greater than. In other words, if it doesn't = exactly what I put, I want it to do that action.

WinGetHandle("") ... Since you must pass an argument in the first parameter, I left it a blank string to be passed, this way it tells the interpreter, I want to get the active window. I believe you could also do WinGetHandle("active").

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...