With the WinActive function, you need quotes around ahk_class MozillaWindowClass
and you donβt need a comma. An infinite loop can be resolved by adding hook $
.
$^l:: if (!WinActive("ahk_class MozillaWindowClass")) and (!WinActive("ahk_class AcrobatSDIWindow")) { WinActivate, ahk_class MozillaWindowClass Send, ^l } else Send, ^l Return
However, recording this method is only necessary if you are using a basic version of AutoHotkey that is outdated.
Unless you have a legitimate reason not to upgrade to AutoHotkey_L (which is unlikely)
you can accomplish what you tried in the first example with the # If directive.
#If !WinActive("ahk_class CalcFrame") && !WinActive("ahk_class Notepad") ^l:: Run, notepad Winwait, ahk_class Notepad Send, test Return f1::traytip,, test
In this example, Ctrl + L and F1 will only work as coded if
the calculator and / or notepad is currently inactive,
otherwise they act as usual.
For those who are not familiar with the abbreviation AutoHotkey,! means no.
source share