LovelyJane Posted September 9, 2014 Share Posted September 9, 2014 Hi, I am trying to have AutoIt activate whichever window of either one type, that I have currently opened, example: I have FF opened but IE and GC is closed, so I want FF window to be activated however I am not sure how to go about with this. IE = Windows Internet Explorer, GC = Google Chrome and FF = Mozilla Firefox Local $titleIE2 = String("AutoIt Forums - Windows Internet Explorer") Local $titleGC2 = String("AutoIt Forums - Google Chrome") Local $titleFF2 = String("AutoIt Forums - Mozilla Firefox") Func ActivateWindow2() Select Case $titleIE2 WinWait($titleIE2,"") If Not WinActive($titleIE2,"") Then WinActivate($titleIE2,"") WinWaitActive($titleIE2,"") Case $titleGC2 WinWait($titleGC2,"") If Not WinActive($titleGC2,"") Then WinActivate($titleGC2,"") WinWaitActive($titleGC2,"") Case $titleFF2 WinWait($titleFF2,"") If Not WinActive($titleFF2,"") Then WinActivate($titleFF2,"") WinWaitActive($titleFF2,"") Case Else Exit EndSelect EndFunc Call ("ActivateWindow2") Link to comment Share on other sites More sharing options...
Kovacic Posted September 9, 2014 Share Posted September 9, 2014 Is the current script failing or erroring out? I don't have the ability to duplicate your environment, so let us know what is, or is not happening and we will do our best. C0d3 is P0etry( ͡° ͜ʖ ͡°) Link to comment Share on other sites More sharing options...
Moderators Solution JLogan3o13 Posted September 9, 2014 Moderators Solution Share Posted September 9, 2014 Why go through all that mess, when you're simply doing a WinActivate off the title? Why not just: While 1 If WinExists("AutoIt Forums -", "") Then WinActivate("AutoIt Forums -", "") Sleep(100) WEnd 232showtime 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
LovelyJane Posted September 9, 2014 Author Share Posted September 9, 2014 (edited) Oh, I am sorry, did not realize about WinExists, its my first time trying this with different window titles, thank you JLogan3o13. Decided to go with: Local $titleTest = String("AutoIt Forums -") Func ActivateWindow2() If WinExists($titleTest, "") Then WinActivate($titleTest, "") WinWaitActive($titleTest,"") EndFunc Call ("ActivateWindow2") I assume While... WEnd is a "always on" code? Hence the Sleep(100) to not make the CPU usage into high usage? Edited September 9, 2014 by LovelyJane Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 9, 2014 Moderators Share Posted September 9, 2014 Correct "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now