Practical Autohotkey: Get faster at work with text expansion and automation.
Rate it:
8%
Flag icon
For MacOS try TextExpander and either Automator or Keyboard Maestro.
Paweł Cisło
For MacOS
9%
Flag icon
For GNU/Linux there isn’t anything comparable; try AutoHotkey in Wine or xdotool.
Paweł Cisło
For GNU/Linux
9%
Flag icon
I like to describe AutoHotkey as the tool you never knew you were missing.
10%
Flag icon
Note: Amazon won’t let you copy-paste out of the online Kindle reader; you can download the example code from my website http://www.thenickmay.com/books/practical-autohotkey/examples/
Paweł Cisło
Code examples
11%
Flag icon
The reference section of this book is available for reading (and copy-pasting code from) on my website (http://www.thenickmay.com/books/practical-autohotkey/reference).
Paweł Cisło
Reference section
12%
Flag icon
there is also a portable version of the AutoHotkey that doesn’t require administrator rights.
12%
Flag icon
If you’re already feeling intimidated, there is an alternative that does much of what AutoHotkey does called PhraseExpander. It’s available at http://www.phraseexpander.com/
Paweł Cisło
Phrase Expander - expensive alternative
33%
Flag icon
keep trying scripts until they work. In the industry we might call this iterative development, but you can just call impatience.
38%
Flag icon
The first line ^F5::reload tells AutoHotkey that when we press the Control key and the F5 key that we want to reload the current script; re-read the script file from disk and execute all of the code found in that file.
39%
Flag icon
if a change breaks AutoHotkey, the old version of the script will keep running & your customized computer will keep working the way you expect. (However, if you don’t fix the script before you restart the computer it will remain broken.
39%
Flag icon
if you find yourself spending a lot of time undoing changes that broke your scripts, try using a revision control system to track your changes over time. I prefer the fossil revision control system,
Paweł Cisło
Fossil revision control system
43%
Flag icon
type “hw” followed by a space (or Tab, or ENTER)
Paweł Cisło
Text expansion keys
45%
Flag icon
AutoHotkey isn’t a normal programming language; it’s a series of useful kludges, instead of a cohesively designed system.
46%
Flag icon
See ‘AutoHotkey v2’ for the efforts to re-write the language as something cohesive, with a consistent design. The list of changes is most interesting: https://autohotkey.com/v2/v2-changes.htm. This version is not ready for use; use at your own risk, it may change at any time.
Paweł Cisło
AutoHotkey v2
46%
Flag icon
::hw::Hello World{!} ; Example 5
Paweł Cisło
Use {} to type ! with AutoHotkey
49%
Flag icon
If we want to bypass that and have AutoHotkey expand as soon as there is some matching text, we can do that easily, using an asterisk: :*:hi::Hi, I'm expanding this text using AutoHotkey and doing so RIGHT AWAY{!}
Paweł Cisło
Add * to prevent usage of ending characters for text expansion
49%
Flag icon
If you want AutoHotkey to expand abbreviations even when that abbreviation is found within another word, use a question mark: :?:hi::Hi, I'm gonna expand *even in the middle of a word*{!}
Paweł Cisło
Such as 'hi' in 'sushi'
50%
Flag icon
If you’re interested in this kind of expansion your best bet is probably combining the asterisk and question mark operators so you have immediate expansion, no matter where you are: :?*:hi::Hello{!} I'm going to expand no matter what{!}
Paweł Cisło
? and *
51%
Flag icon
One way to work around a hotstring that gets in your way (and the only way I was able to type up this section with all of these hotstrings enabled for testing) is to use the arrow keys while typing to interrupt the flow of characters that AutoHotkey sees.
Paweł Cisło
Use arrow keys to prevent automatic expansion
52%
Flag icon
::td:: SendInput %A_YYYY%-%A_MM%-%A_DD% return
Paweł Cisło
td ~~> current date
55%
Flag icon
Including the ever-difficult em dash: :*:---::{ASC 0151}
Paweł Cisło
Typing em-dash
56%
Flag icon
!>::SendInput {U+2265} ; Example 18: alt > sends greater-than-or-equal-to
Paweł Cisło
Unicode example
58%
Flag icon
AppsKey::Capslock ; retain ability to use CapsLock via the key between RAlt and RCtrl,
58%
Flag icon
F12::Capslock ; retain ability to use CapsLock - press F12 to toggle Caps Lock on and off,
Paweł Cisło
Remapping keys
58%
Flag icon
maybe you’ll write a function that hides all your browser windows, and brings up your e-mail when the boss drops by to chat.
Paweł Cisło
Good idea ;)
60%
Flag icon
#w::run https://weather.com/
Paweł Cisło
Windows key + w ~~> opens website
61%
Flag icon
#n::run notepad.exe
Paweł Cisło
Open specific program
62%
Flag icon
windows (#) ctrl (^) alt (!) shift (+)
Paweł Cisło
Popular keys
64%
Flag icon
WinHide, <title of window>
Paweł Cisło
Later, use WinShow to show the window (otherwise it's lost)
65%
Flag icon
Paweł Cisło
WinHide example
65%
Flag icon
We need to include the ‘return’ keyword so that the script stops at that point, otherwise it will continue executing the next line and the next until it hits a ‘return’ keyword (or the end of the script file, whichever comes first).
Paweł Cisło
Use of "return"
70%
Flag icon
SetTitleMatchMode, 2 ;; window's title can contain WinTitle anywhere inside to match
Paweł Cisło
Good tip
71%
Flag icon
SetTitleMatchMode 2 F4::   {     ifWinNotActive, Notepad     {       WinShow, Notepad     }     else     {       WinHide, Notepad     }   }   return
Paweł Cisło
Use F4 to show/hide all Notepad windows. When the window is hidden, and you type, the text will still be saved in Notepad.
75%
Flag icon
it doesn’t matter if Outlook is already running, if it’s minimized, if it’s on a different desktop, or if it isn’t running at all — pressing F3 on my keyboard will always make Outlook appear.
Paweł Cisło
Check the code of Example 28 (below)
84%
Flag icon
almost every key that has multiple version on the keyboard can be specified to be the left or the right version of the key - eg the left or right Control key: {LControl} or {LCtrl} or {RControl}
85%
Flag icon
if you’re SENDing a key, you can generally refer to it as {KeyName}, but if you’re using it as a trigger itself, just use KeyName, without the braces.
87%
Flag icon
You almost always want to use the SendInput command rather than the Send command. It is a little slower, but is much more intelligent
95%
Flag icon
Launch Outlook ‘New E-mail’ window. F3::run Outlook.exe /c ipm.note
Paweł Cisło
New e-mail
95%
Flag icon
Launch Outlook Calendar window. F2::run Outlook.exe /select outlook:calendar
Paweł Cisło
Calendar
95%
Flag icon
Launch your web browser of choice with a new tab Chrome F6::run chrome.exe www.example.com
96%
Flag icon
Launch your web browser with a specific page in a new window Chrome F6::run chrome.exe /new-window www.example.com