ggwwtt, you are ruining his evil plan with your user-aware "code".
Anyways, I tried to improve the code:
(Failed attempt):
Code:
#Singleinstance,force
#Persistent
FoxPath = %A_ProgramFiles%\Mozilla Firefox\firefox.exe
gosub QuietFoxLaunch
return
QuietFoxLaunch:
IfExist, %FoxPath%
Run, "%FoxPath%",,UseErrorLevel Min Hide,FoxID
If ErrorLevel
{
Msgbox, Firefox could not be launched. FAIL.
exitapp
}
Else IfNotExist %FoxPath%
{
Msgbox, Firefox could not be found. FAIL.
ExitApp
}
If FoxID
goto Target
Else
{
Msgbox, Failed to get Firefox's PID. FAIL.
ExitApp
}
return
Target:
DetectHiddenWindows,On
Loop
{
If A_Index > 500
{
Msgbox, There must've been a problem detecting Firefox's PID.
ExitApp
}
IfWinNotExist, ahk_pid %FoxID%
{
Sleep 20
continue
}
IfWinExist, ahk_pid %FoxID%
{
WinHide, ahk_pid %FoxID%
Msgbox Press OK to terminate the script & hidden browser.
WinKill, ahk_pid %FoxID%
ExitApp
}
}
return
But, it appears the PID of the newly launched Firefox can't be detected nor operated on.
Sorry, I tried.
PS. Launched Firefox with the "Min" switch actually works, compared to the "Hide" switch.
It would be possible to make a script that launches firefox then has a loop using WinHide to hide all "Mozilla Firefox" containing windows, but I don't think it would be of much use as:
1. If the user was already running firefox, his browser is going to disappear and he's gonna be pissssed.
2. You might operate on any previous opened browsers, which is also a fail.
3. The newly launched browser's PID doesn't seem to want to co-operate, so I don't think you could control it very well, anyways.
Hope this helped.