Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
it is suggested that you put things into
#IfWinActive window_condition ... #IfWinActive
Include¶
You can use
#include file_pathto include a AutoHotKey scripts (as if the content of the included file appears exactly there).use #include path_to_dir to change the working directory for subsequent #includes and then use #include with relative path this makes things much more conveninet
Syntax¶
Lines that start with a semicolon are comments and thus not executed.
Commands in AutoHotkey are case-insensitive.
!is a special character in AutoHotkey and is cannot be used directly in hotstrings. Use{!}to represent a literal!. {{} literal { {}} literal }Leading/trailing spaces in hotstring definitions are ignored. To use literal leading/trailing spaces in a hotstring definition, use {Space} instead. Actually you always use {Space} to replace literal spaces.
{+} literal plus
You cannot put
;comentafter a command in a line, instead, you have to start a new line ```%``: literal % or you can use continuation mode () or use SendRaw ...take another look at the ignoring case functionality!!!
if you want to use AutoHotkey to automatically type in password for in, you cannot use ````` in the password.
General Tips¶
Do not define too many hotstrings that you even do not remember to use. Generally speaking, only whole (long) sentenses and extremely frequntly used short phrases are useful.
When sending a key, you can specify the number of repeated time instead of doing it manually. For example, instead of
send {Left}{Left}{Left}, you can usesend {Left 3}.You can use
GroupAddto define window groups (to be used byIfWinActiveor#IfWinActive.#IfWinActive(without anything following) matches any window.Symbolic links (made in Cygwin/MobaXterm) and shortcuts (created in Windows) of scripts cannot be used for AutoHotkey. However, hard links (made in Cygwin/Mobaxterm) work well.
Order of hotstring and hotkeys matters. For example, if you have both
/uandudefined in AutoHotkey, you have to put/ubeforeu. Otherwise,uwill be triggered when you type in/u. Generally speaking, if you have two hotstrings/hotkeysAandBdefined andBis a substring ofA, you need to put the definition ofAbeforeB.AutoHotkey ignores the case of triggers by default, which makes hotstrings to adjust cases according to cases of triggers. For example, if you define
:O:mma:mathematica, thenMMAis expanded toMATHEMATICA,Mmais expanded toMathematicaandmmais expanded tomathematica.
ahk_class of Windows¶
You can use
AU3_Spy.exeto get theahk_classinformation of a window.IMWindowClass: Microsoft Lync Office Communicator
MozillaWindowClass: Firefox
MozillaUIWindowClass: Thunderbird
IEFrame: IE Explorer
rctrl_renwnd32: Outlook
Chrome_WidgetWin_1: Chrome
PuTTY: putty
mintty: mintty
Useful Options/Functions/Commands¶
SetTitleMatchModesets the matching behavior of the WinTitle parameter in commands such as WinWait.IfWinActive/IfWinNotActive
Questions¶
How to reuse path? and is it possible to use windows environment variables in AutoHotkey scripts?
is it possible to specify a different script location?
can ahk be used with regular expression?
is it possible to let AutoHotkey popup a list of values to choose from like AutoKey does? This makes things more convenient many times ...