Loop and Incremente number in .exe

01/07/2015 02:44 frankhack1#1
Hi !

I have 10 Firefox.exe (different Profiles), each one of them with the name:
Firefox_10.exe
Firefox_11.exe
Firefox_12.exe
Firefox_13.exe
Firefox_14.exe
Firefox_15.exe
Firefox_16.exe
Firefox_17.exe
Firefox_18.exe
Firefox_19.exe
Firefox_20.exe

I'm trying to do a script that search If Firefox_10 process exists, if YES, then open next Firefox... in this case Firefox_11 is the next Firefox, but it may happen Firefox_11 is also open, so loop till it finds a Firefox process that is not open and open it. The count starts at Firefox_10 and ends at Firefox_20, I don't want to close any process, just jump it and try to open next Firefox that is not open yet.

** Note: I need to open only one Firefox, the one that is free in numerical order, so if Firefox_10.exe is open and Firefox_13.exe is open, then the script should open Firefox_11.exe only and not Firefox_11.exe, Firefox_12.exe, etc..

I have then:

Code:
$start = 10
   While $start <= 20
     If Not ProcessExists("Firefox_"&$start&".exe") Then
       Run("C:\Users\admin\Desktop\OneDrive\SETTINGS\Firefox Stuff\Firefox Light\Mozilla Firefox 31.0\04_Ejecutables\Ejecutables\Firefox_"&$start&".exe")
       EndIf
$start += 1
   WEnd
So this script sucesfully search only for those Firefox that are not open yet and it open them all, that is the problem, I just need ONE firefox to open, not all the available ones.

Regards
01/07/2015 03:55 YatoDev#2
Exitloop in first found
01/07/2015 15:06 frankhack1#3
Great! It did work, now I have another issue related to this.

After it finds and open only one Firefox (the one available in numerical order), I need to wait for 2 minutes since the Firefox have a lot of imacros files and it hangs when is firstly open, so that I have done it well, the issue is that I need that Firefox to be focus after the 2 min has passed. This is what I have tried:

Code:
$start = 10
   While $start <= 20

If Not ProcessExists("Firefox_"&$start&".exe") Then
       Run("C:\Users\admin\Desktop\Firefox_"&$start&".exe -no-remote -P Firefox_"&$start&" file:///C:/Users/admin/Desktop/OneDrive/SETTINGS/Paginas%20Falsas/blank.html")
Exitloop
MsgBox(0, "Title", "Firefox_"&$start&"", 1)

EndIf

$start += 1
   WEnd

Sleep(60000) ; <--- 1 minute
Sleep(60000) ; <--- 1 minute
AutoItSetOption('WinTitleMatchMode', 2)
$tbWin = 'Firefox_"&$start&"' ; ************ HERE THE ERROR: this $start variabla is not taken in count and cause of that, the Firefox that was opened is not getting focus **********
WinActivate($tbWin)
Sleep(1000)

Sleep(1000)
Send("!d")
ClipPut("imacros://run/?m=macros.js")
Send("^v")
Send("{ENTER}")
01/07/2015 17:07 YatoDev#4
WinTitleMatchMode is a bad idea in this case.

"Firefox_" & $start

And MsgBox(0, "Title", "Firefox_"&$start&"", 1) will be never reached
-> MsgBox(0, "Title", "Firefox_" & $start, 1) is enough
01/08/2015 13:03 frankhack1#5
Hi !

"
WinTitleMatchMode is a bad idea in this case.

"Firefox_" & $start
"

I didn't get it, so WinTitleMatchMode is a bad idea in this case and this is the solution? "Firefox_" & $start ? so I should put ?

Code:
AutoItSetOption('WinTitleMatchMode', 2)
$tbWin = "Firefox_" & $start
WinActivate($tbWin)
01/08/2015 14:38 YatoDev#6
Quote:
Originally Posted by frankhack1 View Post
Hi !

"
WinTitleMatchMode is a bad idea in this case.

"Firefox_" & $start
"

I didn't get it, so WinTitleMatchMode is a bad idea in this case and this is the solution? "Firefox_" & $start ? so I should put ?

Code:
AutoItSetOption('WinTitleMatchMode', 2)
$tbWin = "Firefox_" & $start
WinActivate($tbWin)
$tbWin = "Firefox_" & $start
WinActivate($tbWin)

without wintitlematchmode
01/09/2015 01:25 frankhack1#7
Great, it did work, thanks a lot!