Note to Self: AutoHotKey on Windows

Autohotkey, my new favorite productivity program on Windows, is a powerful tool that automates tasks. I use it at work primarily for launching programs at startup and switching among my most often used programs.

Example Code #1, Program Startup

A modified exerpt from my AM startup script. Launch several excel sheets and launches chrome. Line prefixed with semicolon is the comment. Simply put the code in a text file and save it in .ahk format. Open the file with the AutoHotKey program to run the script.

; Script Function:
;    AM startup

; Use excel to launch your custom sheet. Ask program to pause, i.e. sleep 9000, not to overwhelm PC
Run C:\Program Files\Microsoft Office\Office14\EXCEL.EXE "C:\your_sheet1.xlsx"
sleep 9000

; Use excel to launch your custom sheet, in read only mode
Run C:\Program Files\Microsoft Office\Office14\EXCEL.EXE /r "C:\your_sheet2.xlsx"
sleep 9000

; Launch chrome
Run C:\Program Files\Chrome.EXE
Example Code #2, Restore Windows

This script first sets up the ToggleWinMinimize function, and sets up keyboard shortcut minimizing and restoring windows by calling this function.

; Initilizes the ToggleWinMinimize function

DetectHiddenWindows, Off
IfWinActive, %TheWindowTitle%
WinMinimize, %TheWindowTitle%
IfWinExist, %TheWindowTitle%
Winget, winid, ID, %TheWindowTitle%
DllCall("SwitchToThisWindow", "UInt", winid, "UInt", 1)


; Sets up keyboard shortcut here:
; Alt + Shift + D brings the following program to front / miniize
!^d:: ToggleWinMinimize("[Window Name #1, use Window Spy of AutoHotkey to determine]")
; Alt + Shift + V brings window #2 to front / minimize
!^v:: ToggleWinMinimize("[Window Name #2, again use Window Spy]")
; Alt + Shift + C brings calculator to front / minimize