The following script works to open Firefox's location/"awesome" bar from anywhere using control-l
, except when using Acrobat/Adobe reader. This is because control-l
in Acrobat goes full screen. It works, but it's ugly and uses nested #ifWinNotActive
.
#IfWinNotActive, ahk_class MozillaWindowClass
#IfWinNotActive, ahk_class ahk_class AcrobatSDIWindow
^l::
WinActivate, ahk_class MozillaWindowClass
Send, ^l
return
#IfWinNotActive
#IfWinNotActive
The below code replacement doesn't work. Autohotkey doesn't complain with errors, but ignores the !WinActive conditionals and furthermore appears to become caught in an infinite loop. Any ideas why? (I tried the return statement both before and after the closing bracket.)
^l::
if (!WinActive(ahk_class,MozillaWindowClass)) and (!WinActive(ahk_class,AcrobatSDIWindow)) {
WinActivate, ahk_class MozillaWindowClass
Send, ^l
}
return
Multiple conditions in if statement 1 and comparison = for this to work normally both conditions provided with should be true. If the first condition falls... 2 or Comparison = for this to work normally either condition needs to be true. The compiler checks the first condition... More ...
Last Updated : 26 Mar, 2020 If-else conditional statement is used in Python when a situation leads to two conditions and one of them should hold true.
Excel If and function. If you want to test multiple conditions and want every condition evaluates to true, then you need to use the AND function. Take a dataset listed in the screenshot. To evaluate commission, put the formula in the Commission box. =IF (AND (B2>=150,C2>=150),10%,IF (AND (B2>=101,C2>=101),7%,IF (AND (B2>=51),5%,IF (AND ...
VBA IF Statement with Multiple Conditions: ElseIF Statement If you have multiple conditions and you want to extract the result by testing all the conditions with the IF statement, then you can utilize the ElseIF statement in VBA Excel. In the following section, we will show you the example with a VBA code.
With the WinActive function you need quotes around ahk_class MozillaWindowClass
and you don't need the comma. The infinite loop could be resolved by adding a hook $
.
$^l::
if (!WinActive("ahk_class MozillaWindowClass"))
and (!WinActive("ahk_class AcrobatSDIWindow"))
{
WinActivate, ahk_class MozillaWindowClass
Send, ^l
} else
Send, ^l
Return
However, writing it this way is only necessary if you are using AutoHotkey basic, which is out of date.
Unless you have a legitimate reason for not upgrading to AutoHotkey_L (which is unlikely)
you can accomplish what you were trying 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
#If
In this example Ctrl+L and F1 will only work as coded if
calculator and/or notepad are not currently active,
otherwise they act as they normally would.
For anyone not familiar with AutoHotkey shorthand, !
means not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With