Skip to content

Instantly share code, notes, and snippets.

@tkt028
Created June 5, 2014 12:18
Show Gist options
  • Save tkt028/668bd52f2d09e09a1db2 to your computer and use it in GitHub Desktop.
Save tkt028/668bd52f2d09e09a1db2 to your computer and use it in GitHub Desktop.
Sample Autohotkey in Windows
; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
; semicolon, such as this one, are comments. They are not executed.
; This script has a special filename and path because it is automatically
; launched when you run the program directly. Also, any text file whose
; name ends in .ahk is associated with the program, which means that it
; can be launched simply by double-clicking it. You can have as many .ahk
; files as you want, located in any folder. You can also run more than
; one .ahk file simultaneously and each will get its own tray icon.
; SAMPLE HOTKEYS: Below are two sample hotkeys. The first is Win+Z and it
; launches a web site in the default browser. The second is Control+Alt+N
; and it launches a new Notepad window (or activates an existing one). To
; try out these hotkeys, run AutoHotkey again, which will load this file.
;; =================================================================
; Important function
; - Try the `WinActivateBottom` command instead of `WinActivate`.
; This activates the LEAST recently used window - and seeing as when you activate that, it's no longer the least recently used, this can be used to loop through every window.
; >> ref: http://superuser.com/questions/120920/can-i-switch-between-windows-of-the-same-type-using-autohotkey
; ===========================
; set Matching Mode to use Regular Expression
SetTitleMatchMode, RegEx
; ===========================
; Swap Capslock and Control in Windows
; - http://www.emacswiki.org/emacs/MovingTheCtrlKey#toc17
;+Capslock::Capslock ; make shift+Caps-Lock the Caps Lock toggle
;Capslock::Control ; make Caps Lock the control button
; ===========================
^!r::Reload ; Assign Ctrl-Alt-R as a hotkey to restart the script.
^!e::Edit ; Assign Ctrl-Alt-E to opens the script for editing.
#F1::WinMinimize, A
#b::WinActivate, Windows Media Player
#r::WinActivate, .*Foxit Reader
#q::WinActivate, Sticky Note
; ================= Emacs
#1::
IfWinExist .*emacs@.*
WinActivateBottom, .*emacs@.*
else
Run D:\HAJIME\SOFTs\emacs-24.3\bin\emacs.exe
return
; ================= ELCA Imputation
#p::
Run C:\Program Files (x86)\ELCA\Imputations\imp.exe
return
; ================= Windows - Snipping Tool
#s::
Run C:\Windows\system32\SnippingTool.exe
return
; ================= Windows - putty
#u::
IfWinExist .*PuTTY
WinActivateBottom, .*PuTTY
else
Run D:\HAJIME\SOFTs\networking-putty\putty.exe
return
; ================= hajime - random image gallery
#i::
Run http://hajimezhao.github.io/bookmarks.public/slideshow/
return
; ================= Nodepad++
#w::
IfWinExist .*Notepad++
WinActivate, .*Notepad++
else
Run C:\Program Files (x86)\Notepad++\notepad++.exe
return
; ================= Gisto
#g::
IfWinExist .*Gisto
WinActivate, .*Gisto
else
Run C:\Users\tkt\AppData\Roaming\Gisto\gisto.exe
return
; ================= WinMerge
#x::
IfWinExist .*WinMerge
WinActivate, .*WinMerge
else
Run C:\Program Files (x86)\WinMerge\WinMergeU.exe
return
; ================= TortoiseSVN
#t::
IfWinExist .*Tortoise.*
WinActivateBottom, .*Tortoise.*
return
; ================= WinSCP
#h::
IfWinExist .*WinSCP
WinActivate, .*WinSCP
else
Run C:\Program Files (x86)\WinSCP\WinSCP.exe
return
; ================= Microsoft Outlook
#a::
IfWinExist .*Microsoft Outlook
WinActivateBottom, .*Microsoft Outlook
else
Run C:\Program Files (x86)\Microsoft Office\OFFICE11\OUTLOOK.EXE
return
; ======================= Oracle SQL Developer
#d::
IfWinExist Oracle SQL Developer
WinActivate, Oracle SQL Developer
else
Run D:\Projects\Impex08\tools\sqldeveloper64-3.1.06.44-no-jre\sqldeveloper\sqldeveloper.exe
return
; ======================= FreeCommander
#f::
IfWinExist .*FreeCommander
WinActivate, .*FreeCommander
else
Run C:\Program Files (x86)\FreeCommander\FreeCommander.exe
return
; =======================
#n::
IfWinActive, .*Microsoft Word
{
WinActivateBottom, .*Microsoft Word
return
}
IfWinExist .*Microsoft Word
WinActivate, .*Microsoft Word
else
Run C:\Program Files (x86)\Microsoft Office\OFFICE11\WINWORD.EXE
return
; =======================
#m::
IfWinActive, .*Microsoft Excel
{
WinActivateBottom, .*Microsoft Excel
return
}
IfWinExist .*Microsoft Excel
WinActivate, .*Microsoft Excel
else
Run C:\Program Files (x86)\Microsoft Office\OFFICE11\EXCEL.EXE
return
; ======================= Spark
#k::
WinActivateBottom, .*ev-lagapeo
;WinActivateBottom, .*ev-lagapeo, ahk_class SunAwtFrame
; ======================= Volume control
; ref: http://xahlee.info/mswin/autohotkey_examples.html
#NumpadAdd::Send {Volume_Up 2} ; increase sound level
#NumpadSub::Send {Volume_Down 2} ; decrease sound level
; =======================================================
; Note: From now on whenever you run AutoHotkey directly, this script
; will be loaded. So feel free to customize it to suit your needs.
; Please read the QUICK-START TUTORIAL near the top of the help file.
; It explains how to perform common automation tasks such as sending
; keystrokes and mouse clicks. It also explains more about hotkeys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment