Skip to content

Instantly share code, notes, and snippets.

@johnlindquist
Created January 19, 2016 16:49
Show Gist options
  • Save johnlindquist/7b80dc14bd10dc64c0fa to your computer and use it in GitHub Desktop.
Save johnlindquist/7b80dc14bd10dc64c0fa to your computer and use it in GitHub Desktop.
; Colemak layout for AutoHotkey (MS Windows)
; 2006-01-01 Shai Coleman, http://colemak.com/ . Public domain.
; See http://www.autohotkey.com/ for more information
; For this to work you have to make sure that the US (QWERTY) layout is installed,
; that is set as the default layout, and that it is set as the current layout.
; Otherwise some of the key mappings will be wrong.
;
; This is mainly useful for those who don't have privileges to install a new layout
; This doesn't support the international features of the Colemak layout.
#MaxHotkeysPerInterval 20000
#InstallKeybdHook
#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
; semicolon, such as this one, are comments. They are not executed.
; See http://duartes.org/gustavo/blog/home-row-computing for more information on this script
; See the AutoHotKey docs at http://www.autohotkey.com/docs/ for AutoHotKey documentation
; Most of the syntax is described at http://www.autohotkey.com/docs/Hotkeys.htm
DebugMessage(str)
{
global h_stdout
DebugConsoleInitialize() ; start console window if not yet started
str .= "`n" ; add line feed
DllCall("WriteFile", "uint", h_Stdout, "uint", &str, "uint", StrLen(str), "uint*", BytesWritten, "uint", NULL) ; write into the console
WinSet, Bottom,, ahk_id %h_stout% ; keep console on bottom
}
DebugConsoleInitialize()
{
global h_Stdout ; Handle for console
static is_open = 0 ; toogle whether opened before
if (is_open = 1) ; yes, so don't open again
return
is_open := 1
; two calls to open, no error check (it's debug, so you know what you are doing)
DllCall("AttachConsole", int, -1, int)
DllCall("AllocConsole", int)
dllcall("SetConsoleTitle", "str","Paddy Debug Console") ; Set the name. Example. Probably could use a_scriptname here
h_Stdout := DllCall("GetStdHandle", "int", -11) ; get the handle
WinSet, Bottom,, ahk_id %h_stout% ; make sure it's on the bottom
WinActivate,Lightroom ; Application specific; I need to make sure this application is running in the foreground. YMMV
return
}
CheckAppsKey(){
if(not GetKeyState("F13", "P"))
{
if(GetKeyState("Shift")){
;Send {Shift Up}
;DebugMessage("shift")
}
if(GetKeyState("Ctrl")){
;Send {Ctrl Up}
;DebugMessage("ctrl")
}
if(GetKeyState("LWin")){
;Send {LWin Up}
;DebugMessage("win")
}
if(GetKeyState("LAlt")){
;Send {LAlt Up}
;DebugMessage("alt")
}
if(GetKeyState("F13")){
Send {F13 Up}
;DebugMessage("alt")
}
if(GetKeyState("Tab")){
;Send {Tab Up}
;DebugMessage("alt")
}
if(GetKeyState("AppsKey")){
;Send {AppsKey Up}
;DebugMessage("alt")
}
}
}
SetTimer, CheckAppsKey, 100
return
ReleaseModifiers(timeout := "") ; timeout in ms
{
static aModifiers := ["Ctrl", "Alt", "Shift", "Win"]
startTime := A_Tickcount
while (isaKeyPhysicallyDown(aModifiers))
{
if (timeout && A_Tickcount - startTime >= timeout)
return 1 ; was taking too long
sleep, 5
}
return
}
isaKeyPhysicallyDown(Keys)
{
if isobject(Keys)
{
for Index, Key in Keys
if getkeystate(Key, "P")
return key
}
else if getkeystate(Keys, "P")
return Keys ;keys!
return 0
}
; F13 + jkl;
F13::Return
F13 up::Return
;F13 & a::Send {Blind}{LWin Down}
;F13 & a up::Send {Blind}{LWin Up}
F13 & r::Send {Blind}{LAlt Down}
F13 & r up::Send {Blind}{LAlt Up}
F13 & s::Send {Blind}{Shift Down}
F13 & s up::Send {Blind}{Shift Up}
F13 & t::Send {Blind}{Ctrl Down}
F13 & t up::Send {Blind}{Ctrl Up}
F13 & v::Send {Blind}{Ctrl Down}{LWin Down}
F13 & v up::Send {Blind}{Ctrl Up}{LWin Up}
F13 & e::Send {Blind}{Up DownTemp}
F13 & e up::Send {Blind}{Up Up}
F13 & n::Send {Blind}{Down DownTemp}
F13 & n up::Send {Blind}{Down Up}
F13 & h::Send {Blind}{Left DownTemp}
F13 & h up::Send {Blind}{Left Up}
F13 & i::Send {Blind}{Right DownTemp}
F13 & i up::Send {Blind}{Right Up}
F13 & o::Send {Blind}{Ctrl Down}{s Down}
F13 & o up::Send {Blind}{Ctrl Up}{s Up}
F13 & k::Send {Blind}{BS DownTemp}
F13 & k up::Send {Blind}{BS Up}
F13 & .::Send {Blind}{Del DownTemp}
F13 & . up::Send {Blind}{Del Up}
;undo
F13 & m::Send {Blind}{Ctrl Down}{z Down}
F13 & m up::Send {Blind}{Ctrl Up}{z Up}
;redo
F13 & ,::Send {Blind}{Ctrl Down}{Shift Down}{z Down}
F13 & , up::Send {Blind}{Ctrl Up}{Shift Up}{z Up}
F13 & d::Send {Blind}{Esc Down}
F13 & d up::Send {Blind}{Esc Up}
F13 & l::Send {Blind}{Home DownTemp}
F13 & l up::Send {Blind}{Home Up}
F13 & u::Send {Blind}{End DownTemp}
F13 & u up::Send {Blind}{End Up}
F13 & p::Send {Blind}{w Down}
F13 & p up::Send {Blind}{w Up}
F13 & /::Send {Blind}{Alt Down}{/ Down}
F13 & / up::Send {Blind}{Alt Up}{/ Up}
F13 & Enter::Send {Blind}{Ctrl Down}{Shift Down}{p Down}
F13 & Enter up::Send {Blind}{Ctrl Up}{Shift Up}{p Up}
; F13 + dbwer
; F13 & e::Send {Blind}{Ctrl Down}{Shift Down}{n Down}
; F13 & e up::Send {Blind}{Ctrl Up}{Shift Up}{n Up}
; F13 & z::Send {Blind}{Ctrl Down}{Alt Down}{Shift Down}{z Down}
; F13 & z up::Send {Blind}{Ctrl Up}{Alt Up}{Shift Up}{z Up}
; F13 & b::Send {Blind}{Ctrl Down}{Left Down}
; F13 & b up::Send {Blind}{Ctrl Up}{Left Up}
;F13 & 7::Send {Blind}{Ctrl Down}{Alt Down}{F13 Down}
;F13 & 7 up::Send {Blind}{Ctrl Up}{Alt Up}{F13 Up}
;F13 & 3::Send {Blind}{Ctrl Down}{f3 Down}
;F13 & 3 up::Send {Blind}{Ctrl Up}{f3 Up}
; Make Windows Key + Apps Key work like Caps Lock
#F13::Capslock
;ctrl left
F13 & j::Send {Blind}{Ctrl Down}{Left DownTemp}
F13 & j up::Send {Blind}{Ctrl Up}{Left Up}
;ctrl right
F13 & y::Send {Blind}{Ctrl Down}{Right DownTemp}
F13 & y up::Send {Blind}{Ctrl Up}{Right Up}
F13 & g::Send {Blind}{LWin Down}{Tab Down}
F13 & g up::Send {Blind}{LWin Up}{Tab Up}
F13 & '::Send {Blind}{Ctrl Down}{Space Down}
F13 & ' up::Send {Blind}{Ctrl Up}{Space Up}
;F13 & ,::Send {Blind}{f5 Down}
;F13 & , up::Send {Blind}{f5 Up}
F13 & [::Send {Blind}{LWin Down}{[ Down]}
F13 & [ up::Send {Blind}{Lwin Up}{[ Up]}
F13 & ]::Send {Blind}{LWin Down}{] Down]}
F13 & ] up::Send {Blind}{Lwin Up}{] Up]}
F13 & \::Send {Blind}{LWin Down}{\ Down]}
F13 & \ up::Send {Blind}{LWin Up}{\ Up]}
;F13 & Space::Send {Blind}{Pause Down}
;F13 & Space up::Send {Blind}{Pause Up}
;alt+j
Tab & j::Send {Blind}{Ctrl Down}{j DownTemp}
Tab & j up::Send {Blind}{Ctrl Up}{j Up}
;=
Tab & y:: Send `=
Tab & `;:: Send `>
;{}
Tab & n::Send +[
Tab & e::Send +]
;()
Tab & l::Send +9
Tab & u::Send +0
;() with thumbs
Tab & s::Send +9
Tab & t::Send +0
;[]
Tab & i::Send [
Tab & o::Send ]
;<>
Tab & a::Send `<
Tab & r::Send `>
Tab::Send {Tab}
;find
F13 & f::Send {Blind}{Ctrl Down}{f DownTemp}
F13 & f up::Send {Blind}{Ctrl Up}{f Up}
;New Desktop
Tab & g::Send {Blind}{LWin Down}{Ctrl Down}{d DownTemp}
Tab & g up::Send {Blind}{LWin Up}{Ctrl Up}{d Up}
;Close Desktop
Tab & w::Send {Blind}{LWin Down}{Ctrl Down}{f4 DownTemp}
Tab & w up::Send {Blind}{LWin Up}{Ctrl Up}{f4 Up}
;Windows + Tab
;F13 & c::Send {Blind}{LWin Down}{Tab Down}
;F13 & c up::Send {Blind}{LWin Up}{Tab Up}
Alt & Tab::Send {Blind}{Alt Down}{Tab Down}
Alt & Tab up::Send {Blind}{Alt Up}{Tab Up}
Shift & Tab::Send {Blind}{Shift Down}{Tab Down}
Shift & Tab up::Send {Blind}{Shift Up}{Tab Up}
; `::`
; 1::1
; 2::2
; 3::3
; 4::4
; 5::5
; 6::6
; 7::7
; 8::8
; 9::9
; 0::0
; -::-
; =::=
; q::q
; w::w
; e::f
; r::p
; t::g
; y::j
; u::l
; i::u
; o::y
; p::`;
; [::[
; ]::]
; \::\
; a::a
; s::r
; d::s
; f::t
; g::d
; h::h
; j::n
; k::e
; l::i
; `;::o
; '::
; z::z
; x::x
; c::c
; v::v
; b::b
; n::k
; m::m
; ,::,
; .::.
; /::/
;{}
; <!j:: Send +[
; <!k:: Send +]
;()
; <!l:: Send +9
; <!`;:: Send +0
;[]
; <!a:: Send [
; <!s:: Send ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment