0
votes

If browser is not already open. make the browser open. If browser is already open. make the browser close.

I've found a script but this does not close the browser

!f::
firefox = C:\Program Files\Mozilla Firefox\Firefox.exe
IfWinExist, firefox     ; Title of the prog
    {
    WinActivate
    WinClose
    }
else
    {
    Run, C:\Program Files\Mozilla Firefox\Firefox.exe "github.com"
    Run,  C:\Program Files\Mozilla Firefox\Firefox.exe "stackoverflow.com"
    }

How can I close the program already exists?

1

1 Answers

0
votes

Try with this:

!f::
firefox = C:\Program Files\Mozilla Firefox\Firefox.exe
IfWinExist, "ahk_exe firefox.exe"     ; Executable name
    {
    WinActivate
    WinClose
    }
else
    {
    Run, C:\Program Files\Mozilla Firefox\Firefox.exe "github.com"
    Run,  C:\Program Files\Mozilla Firefox\Firefox.exe "stackoverflow.com"
    }