Sign in to follow this  
Followers 0
aswfreak29

Switching between two of the same windows

8 posts in this topic

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?

Share this post


Link to post
Share on other sites



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.

[center]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.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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.

Edited by aswfreak29

Share this post


Link to post
Share on other sites

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?

[center]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.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

I see... Look at WinActivate()

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


[center]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.[/center]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

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