Practices Contents

AutoHotKey - Tips

Definitions:
A Hotkey is the combination of keys where at least one key is pressed down followed by another trigger their programmed result.
A Hotstring is the combination of keys when at the end of their entry trigger either instantly or by the entry of a non-character such as a space or a comma their programmed result.

Tip#01 Place your “myscript.ahk” file in an easy accessible folder for quick retrieval and consider editing it with Notepad++.
Tip#02 “AltGr” and “PrtSc”keys: In the AHK Help File (Usage and Syntax:: Hotkeys), one will find that the “AltGr” key is defined as <^>! whereas “PrtSc” key can only be used as “PrintScreen &” eg. “PrintScreen & b” is a hotkey combination of “PrtSc” key and the letter “b”.
Tip#03 Unusual Character key combos – those that are very unlikely to be found in normal text; eg the non-alphabet character “]” is always followed by a space. Thus the hotstring combo ]9 can useful.
Tip#04 Position of Keys: the combination use of the “Ctl”+“Sht” is useful for a right-handed person. For a left-handed person, the use of the “AltGr”+“Ctl” combination would be more natural. Examine the keyboard of similar combinations eg “;”+ “'”
Tip#05 Quick Reload: When making changes to the .ahk script file and upon saving it, this function will reload the script.
; the Reload function
PrintScreen & r::
Reload
Sleep 200 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
MsgBox, 4,, The hotstring just added appears to be improperly formatted. Would you like to open the script for editing? Note that the bad hotstring is at the bottom of the script.
IfMsgBox, Yes, Edit
return
Tip#06 A Date Hotstring accepted by Excel or LibreOffice Calc:
:*:]d:: ; This hotstring replaces "]d" with the current date
FormatTime, CurrentDateTime,, dd-MMM-yyyy ; It will look like 09-Sep-2019
SendInput %CurrentDateTime%
return
Tip#07 Use a Hotstring to fire several lines of text (a), open a website (b) or a file in your home directory (c)

; a)
:*:lsa??::
(
Local Spiritual Assembly
of the Bahá’ís of ????

)
return
; b)
PrintScreen & c::
Run, https://www.badi-calendar.com/calculator.php
return
; c)
PrintScreen & o::
try
{
Run, %A_MyDocuments%\myTemplate.ott
; With LibreOffice active: opens myTemplate.ott placed in the MyDocuments folder
}
catch
{
MsgBox, 16,, There was a problem opening the file!
Exit
}
AHK setup
Installing AutoHotKey
AHK Intro
Introduction to AutoHotKey
AHK Editing
Getting under the hood
AHK Extras
Bonus functions