Reputation: 2425
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
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