Hisham Hijjawi
Hisham Hijjawi

Reputation: 2425

Running Program Deactivating Window

I have a simple AHK script that opens a website in my default browser (Firefox).

NumPad7::
    Run, www.bbc.com 
return

When I run the program outside of Firefox, it opens the website in a new tab as intended. However, when I am in Firefox and run the script, Firefox is deactivated although the website does open. If I use the hotkey an even number of times it works even when Firefox is open. I have tried using WinActivate after the command but it doesn't work.

Any idea how I can keep Firefox active?

Upvotes: 0

Views: 238

Answers (1)

Relax
Relax

Reputation: 10636

Try to find out which window gets active, this way:

NumPad7::
    Run, www.bbc.com 
    Sleep 500 ; or more
    WinGetTitle, WinTitle, A
    WinGetClass, ActiveClass, A
    MsgBox, Active Window:`n"%WinTitle%"`nahk_class "%ActiveClass%"
return

And this should work:

NumPad7::
    Run, www.bbc.com 
    WinWait, BBC - Homepage - Mozilla Firefox
    WinActivate, BBC - Homepage - Mozilla Firefox
return

Upvotes: 1

Related Questions