I've yet to talk to anyone in real life who knows what AutoHotkey is. This is unfortunate, as it's an awesome piece of software for scripting hotkeys and much more. The AHK script that is always running on my laptop (or even off of my USB drive) is a huge part of what makes my computer 'mine.'
It's remarkably simple to implement some stuff... though it gets tricky when you start doing complex stuff. Fortunately, AHK is fully documented on an easy to navigate website. The support forum is active and full of code examples from others.
How to get AHK on your Windows
system:
- Download and install.
- Create a new .ahk file and open it in a text reader (i.e. notepad/wordpad)
- Read the quick-start guide.
- If you want the .ahk script to run every time you log on to your computer, save the file in (for Windows XP) Start -> Programs -> Startup
- Have fun. Try stuff. Look commands up. Search for
implementations of ideas already done on the Forum.
The annotation of my
AlwaysOnHotkeys.ahk script
You can simply skim this, looking for ideas that you might like to implement (steal).
AlwaysOnHotkeys.ahk | |
; ; AutoHotkey Version: 1.0.46.x ; Language: English ; Platform: Windows XP Pro ; Author: Eric R <redacted@lol.com> ; ; Script Function: ; Various useful functions and shortcuts and hotkeys that are interoperable. Script is run at all times. ; #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SetcapsLockState, AlwaysOff SendMode Input ; Recommended for new scripts due to its superior speed and reliability. #KeyHistory 50 |
Nothing really important.... |
;************************************** ; Volume On-Screen-Display (OSD) -- by Rajat ; http://www.autohotkey.com ; This script assigns hotkeys of your choice to raise and lower the ; master and/or wave volume. Both volumes are displayed as different ; color bar graphs. ;_________________________________________________ ;_______User Settings_____________________________ ; Make customisation only in this area or hotkey area only!! ; The percentage by which to raise or lower the volume each time: vol_Step = 4 ; How long to display the volume level bar graphs: vol_DisplayTime = 500 ; Master Volume Bar color (see the help file to use more ; precise shades): vol_CBM = Black ; Wave Volume Bar color vol_CBW = Blue ; Background color vol_CW = Silver ; Bar's screen position. Use -1 to center the bar in that dimension: vol_PosX = 100 vol_PosY = 950 vol_Width = 200 ; width of bar vol_Thick = 24 ; thickness of bar |
Awesome stuff.... Neccessary after I disabled Dell's keyboard control software stuff. |
; If your keyboard has multimedia buttons for Volume, you can ; try changing the below hotkeys to use them by specifying ; Volume_Up, ^Volume_Up, Volume_Down, and ^Volume_Down: HotKey, #Up, vol_MasterUp ; Win+UpArrow HotKey, #Down, vol_MasterDown HotKey, +#Up, vol_WaveUp ; Shift+Win+UpArrow HotKey, +#Down, vol_WaveDown Hotkey, SC12E, vol_MasterDown Hotkey, SC130, vol_MasterUp HotKey, +SC130, vol_WaveUp ; Shift+FrontButtons HotKey, +SC12E, vol_WaveDown |
The hotkeys controlled by Rajat's script |
;___________________________________________ ;_____Auto Execute Section__________________ ; DON'T CHANGE ANYTHING HERE (unless you know what you're doing). vol_BarOptionsMaster = 1:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBM% CW%vol_CW% vol_BarOptionsWave = 2:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBW% CW%vol_CW% ; If the X position has been specified, add it to the options. ; Otherwise, omit it to center the bar horizontally: if vol_PosX >= 0 { vol_BarOptionsMaster = %vol_BarOptionsMaster% X%vol_PosX% vol_BarOptionsWave = %vol_BarOptionsWave% X%vol_PosX% } ; If the Y position has been specified, add it to the options. ; Otherwise, omit it to have it calculated later: if vol_PosY >= 0 { vol_BarOptionsMaster = %vol_BarOptionsMaster% Y%vol_PosY% vol_PosY_wave = %vol_PosY% vol_PosY_wave += %vol_Thick% vol_BarOptionsWave = %vol_BarOptionsWave% Y%vol_PosY_wave% } #SingleInstance SetBatchLines, 10ms Return ;___________________________________________ vol_WaveUp: SoundSet, +%vol_Step%, Wave Gosub, vol_ShowBars return vol_WaveDown: SoundSet, -%vol_Step%, Wave Gosub, vol_ShowBars return vol_MasterUp: SoundSet, +%vol_Step% Gosub, vol_ShowBars return vol_MasterDown: SoundSet, -%vol_Step% Gosub, vol_ShowBars return vol_ShowBars: ; To prevent the "flashing" effect, only create the bar window if it ; doesn't already exist: IfWinNotExist, vol_Wave { SoundGet, master_mute,MASTER,MUTE ; System-wide mute SoundGet, master_onoff,MASTER,ONOFF ; Laptop's speakers if master_mute = On { Progress, %vol_BarOptionsWave%, , All Muted, vol_Wave } else { if master_onoff = On ; laptop speakers ARE muted { Progress, %vol_BarOptionsWave%, , Ext. Muted, vol_Wave } else { Progress, %vol_BarOptionsWave%, , , vol_Wave } } } IfWinNotExist, vol_Master { ; Calculate position here in case screen resolution changes while ; the script is running: if vol_PosY < 0 { ; Create the Wave bar just above the Master bar: WinGetPos, , vol_Wave_Posy, , , vol_Wave vol_Wave_Posy -= %vol_Thick% Progress, %vol_BarOptionsMaster% Y%vol_Wave_Posy%, , , vol_Master } else Progress, %vol_BarOptionsMaster%, , , vol_Master } ; Get both volumes in case the user or an external program changed them: SoundGet, vol_Master, Master SoundGet, vol_Wave, Wave Progress, 1:%vol_Master% Progress, 2:%vol_Wave% SetTimer, vol_BarOff, %vol_DisplayTime% return vol_BarOff: SetTimer, vol_BarOff, off Progress, 1:Off Progress, 2:Off return ;******************************* |
More of Rajat's script. End result is a bar display of the regular and WAV volumes. |
^RCtrl::run Control Panel |
Pressing both Ctrl keys together opens control panel. |
;^!u:: ;Run sndvol32 ;WinWait ahk_class Volume Control ;WinActivate ahk_class Volume Control ;ControlClick Button3, ahk_class Volume Control ;WinWait ahk_class #32770 ;;Run ahk_class #32770 ;WinActivate ahk_class #32770 ;WinWaitActive ahk_class #32770 ;WinActivate ahk_class #32770 ;ControlClick Button3, ahk_class #32770 ;WinClose ahk_class #32770 ;WinWaitClose ahk_class #32770 ;WinClose ahk_class Volume Control ;return |
The old often non-working method for toggling my laptop's speakers. |
^!s::SoundSet +1, MASTER, ONOFF SC120:: Soundset,+1,MASTER,MUTE,1 SoundPlay, %A_WinDir%/Media/ding.wav ; Mute return |
1. Toggles the laptop's speakers. 2. Plays a sound when I unmute my system. |
^!Space::run C:\Eric\Show Desktop.scf ;Show Desktop is also somewhere in the Windows folder ;^!q:: ^!w::run C:\Program Files\Windows NT\Accessories\wordpad.exe ^!e::Edit ;edit AHK script ^!r::Reload ;reload AHK script... usually after editing or switching to bluetooth audio ^!t::run C:\Program Files\Mozilla Thunderbird\thunderbird.exe ;^!y:: ;^!u:: ^!i::run C:\Program Files\IrfanView\i_view32.exe ;^!o:: ;^!p:: ;^!a:: ^!s::SoundSet, +1, MASTER, ONOFF,1 ^!d::run D:\ ^!f::run C:\Program Files\Mozilla Firefox\firefox.exe ;^!g:: ^!h::run devmgmt.msc ;device manager! ;^!j:: ^!k::Run http://www.facebook.com/photo.php?pid=424143&id=505580901#pid=424143 ;^!l:: ;^!z:: ^!x::run C:\Program Files\CursorXP\CursorXP.exe ;toggles CursorXP (fancy cursors) ^!c::run C:\ ^!v::run sndvol32 ;volume control ^!b:: ; PostMessage 0x0112, 0xF140, 0,, Program Manager ; 0x0112 is WM_SYSCOMMAND -- 0xF140 is SC_SCREENSAVE ;screensaver Sleep 1000 ; if you use this with a hotkey, not sleeping will make it so your keyboard input wakes up the monitor immediately SendMessage 0x112, 0xF170, 1,,Program Manager ; send the monitor into standby (off) mode return ^!n::run C:\Eric ^!m::run C:\Music |
This lists the hotkeys set to
every letter key, in QWERTY order. I've still got quite a few Ctrl+Alt+Letter combinations available. |
;---------------------------------------------------------------- ;--- Ctrl+Alt+B: screensaver launcher ^!b:: PostMessage 0x0112, 0xF140, 0,, Program Manager ; 0x0112 is WM_SYSCOMMAND -- 0xF140 is SC_SCREENSAVE Return |
This runs as a screenshaver a program that turns my screen off until any key is touched. |
#IfWinActive Diablo II LWin::LAlt #IfWinActive |
This prevents me from accidently hitting the Windows key while playing Diablo II |
#IfWinActive Bluetooth Car Control GUI ; Blocks undesirable keys on keypad !F4::return ; Disables Alt + F4 or "Close" LWin::return ; Disables Left windows key #IfWinActive |
|
#IfWinActive Sid Meier's Alpha Centauri SC135::q SC037::] SC04A::_ SC04F::End SC050::Down SC051::PgDn SC04B::Left SC04D::Right SC047::Home SC048::Up SC049::PgUp SC04E::t #IfWinActive |
This remaps the numbers on my bluetooth numpad to the proper direction keys for when I play Sid Meier's Alpha Centauri |
SC10A::run C:\Program Files\AutoHotkey\DOWN.exe /H ; Hibernate ;SC109:: ; SC107::run C:\Program Files\Dell\QuickSet\battery.exe ; Battery Indicator ;SC109:: ; CD Eject ;SC12E:: ; VolDown ;SC130:: ; VolUp |
I got rid of the default Dell software that allowed Fn+F1 to hibernate the computer. THis replaces it with a small program that prompts me whether to hibernate or not. Also remaps the battery indicator key. |
VKB1SC010::SC110 ; bluetooth headphones: forward VKB0SC019::SC119 ; bluetooth headphones: back VKB3SC022::SC122 ; bluetooth headphones: play/pause |
This makes the music controls on my bluetooth headphones actually tell the computer to do something. |
SC15D::º SC112::run C:\Eric ^!SC112::run C:\Documents and Settings\Eric\My Documents +SC112::run C:\Eric\My Pics ;SC053::Backspace ;NumpadDot::. SC124::run C:\Eric\Music ^SC124::run C:\Eric\Music |
Various hotkeys. SC112 is the MediaDirect key on my laptop. |
:c?*:uuU::Ü :c?*:ooO::Ö :c?*:aaA::Ä :c?*:sS::ß :c?*:oO::ö :c?*:aA::ä :c?*:uU::ü :c?*:_-::– ; m-dash :?*:*?*::º¿º :?*:+or-::± :c?*:~G::•G :c?*:~E::•E :c?*:~R::•R ;:o:ar::aristocrat :c*:monday::Monday :c*:tuesday::Tuesday :c*:wednesday::Wednesday :c*:thursday::Thursday :c*:friday::Friday :c*:saturday::Saturday :c*:sunday::Sunday :c:january::January :c:february::February ;:c:march::March :c:april::April ;:c:may::May :c:june::June :c:july::July :c:august::August :c:september::September :c:october::October :c:november::November :c:december::December |
Probably my favorite set of
hotkeys. The first bunch are German letters. If I
type uuU, it gets replaced with Ü. Defining uuU
before uU is
important. I replace most of the months and days with auto uppercase versions. May and march are used elsewhere too often, so they're disabled here. |
#IfWinExist, ELECTR~1.SCR LButton::Enter #IfWinExist |
Old. |
#IfWinActive ahk_class MozillaWindowClass :c?*:`;)q:: ( <img class="smiley" src="http://www-personal.umich.edu/~erelson/ChatzillaSmilies/face-wink.png" alt=""> ) return :c?*:`:Dq:: ( <img class="smiley" src="http://www-personal.umich.edu/~erelson/ChatzillaSmilies/face-laugh.png" alt=""> ) return :c?*::)q:: ( <img class="smiley" src="http://www-personal.umich.edu/~erelson/ChatzillaSmilies/face-smile.png" alt=""> ) return :?*::pq:: ( <img class="smiley" src="http://www-personal.umich.edu/~erelson/ChatzillaSmilies/face-smile.png" alt=""> ) return :c?*:B)q:: ( <img class="smiley" src="http://www-personal.umich.edu/~erelson/ChatzillaSmilies/face-cool.png" alt=""> ) return :c?*::(q:: ( <img class="smiley" src="http://www-personal.umich.edu/~erelson/ChatzillaSmilies/face-sad.png" alt=""> ) return :c?*::'(q:: ( <img class="smiley" src="http://www-personal.umich.edu/~erelson/ChatzillaSmilies/face-cry.png" alt=""> ) return :c?*:o_Oq:: ( <img class="smiley" src="http://www-personal.umich.edu/~erelson/ChatzillaSmilies/face-dizzy.png" alt=""> ) return #IfWinActive |
This is the code that allows me to
insert smilies when coding my website with Kompozer. ![]() Following the smiley with a q triggers this. |
#IfWinActive Xanga - Weblog Entry :c?*:`:):::happy: :c?*:`:(:::sad: :c?*:`;):::winky: :?*:`:P:::silly: :c?*:B):::cool: :c?*:`:D:::laughing: :c?*:o_O:::wtf: :?*:=-o:::stunned: :?*:`:-o:::surprised: #IfWinActive ;*************************************************************** |
Similar to the above, this converts standard smiley codes to Xanga's obscure smiley codes. |
;***************************************************************
CapsLock & `::Send {Blind}{BS} ;CapsLock & +`::Send {Blind}? CapsLock & +Space::Send {Enter} CapsLock & +q::Send {Blind}p CapsLock & +w::Send {Blind}o CapsLock & +e::Send {Blind}i CapsLock & +r::Send {Blind}u CapsLock & +t::Send {Blind}y CapsLock & +y::Send {Blind}t CapsLock & +a::Send {Blind}' CapsLock & +s::Send {Blind}l CapsLock & +d::Send {Blind}k CapsLock & +f::Send {Blind}j CapsLock & +g::Send {Blind}h CapsLock & +h::Send {Blind}g CapsLock & +z::Send {Blind}{.} CapsLock & +x::Send {Blind}{,} CapsLock & +c::Send {Blind}m CapsLock & +v::Send {Blind}n CapsLock & +b::Send {Blind}b CapsLock & +1::Send {Blind}0 CapsLock & +2::Send {Blind}9 CapsLock & +3::Send {Blind}8 CapsLock & +4::Send {Blind}7 CapsLock & +5::Send {Blind}6 CapsLock & +6::Send {Blind}5 ;#IfWinActive Hellgate:London (x86 DX9) ;CapsLock & a::Send {F1} ;Capslock & s::Send {F2} ;Capslock & d::Send {F3} ;Capslock & e::Send 5 ;Capslock & q::Send 4 ;Capslock & w::Send w ;#IfWinActive |
This implements a mirror keyboard. It allows me to type most stuff with just my left hand.... I haven't practiced it much though. |