Jump to content

Problem with Select... Case

Go to solution Solved by JLogan3o13,

Recommended Posts

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()
        Case $titleIE2
            If Not WinActive($titleIE2,"") Then WinActivate($titleIE2,"")
        Case $titleGC2
            If Not WinActive($titleGC2,"") Then WinActivate($titleGC2,"")
        Case $titleFF2
            If Not WinActive($titleFF2,"") Then WinActivate($titleFF2,"")
        Case Else

Call ("ActivateWindow2")
Link to comment
Share on other sites

  • Moderators
  • Solution

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

"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

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

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 by LovelyJane
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...