Skip to content

Instantly share code, notes, and snippets.

@vaemendis
Last active January 1, 2020 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaemendis/a4a2cb3b64256814ce6f70c8d8ef770a to your computer and use it in GitHub Desktop.
Save vaemendis/a4a2cb3b64256814ce6f70c8d8ef770a to your computer and use it in GitHub Desktop.
Layout
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; =================================
; ======== Sound control ==========
; =================================
#If MouseIsOver("ahk_class Shell_TrayWnd") or MouseIsOver("ahk_class Shell_SecondaryTrayWnd")
WheelUp::Send {Volume_Up}
WheelDown::Send {Volume_Down}
#If
MouseIsOver(WinTitle)
{ MouseGetPos,,, Win
Return WinExist(WinTitle . " ahk_id " . Win)
}
; Numpad +
$SC04E::
Send {Volume_Up 2}
return
; Numpad -
$SC04A::
Send {Volume_Down 2}
return
; Numpad *
$SC037::
Send {Volume_Mute}
return
; =================================
; ======== Shift keys ========
; =================================
; shift produces parenthesis
LShift::
RShift::
Shift::Send % (A_ThisHotkey = "LShift" ? "(" : ")")
; =================================
; ======== Layer functions ========
; =================================
Layered(defaultKey, alterKey)
{
if GetKeyState("CapsLock", "T") = 1
Send {Blind}{%alterKey%}
else if GetKeyState("CapsLock", "T") = 0
Send {Blind}{%defaultKey%}
return
}
LayeredControl(defaultKey, alterKey)
{
if GetKeyState("CapsLock", "T") = 1
Send {Blind}{CtrlDown}{%alterKey%}{CtrlUp}
else if GetKeyState("CapsLock", "T") = 0
Send {Blind}{%defaultKey%}
return
}
Noop(defaultKey)
{
if GetKeyState("CapsLock", "T") = 1
SoundBeep
else if GetKeyState("CapsLock", "T") = 0
Send {Blind}{%defaultKey%}
return
}
; =================================
; ======== Digits row ========
; =================================
$SC029::Noop("SC029")
$SC002::Layered("SC002","!")
$SC003::Layered("SC003","""")
$SC004::Layered("SC004","£")
$SC005::Layered("SC005","$")
$SC006::Layered("SC006","%")
$SC007::Layered("SC007","^")
$SC008::Layered("SC008","&")
$SC009::Layered("SC009","*")
$SC00A::Layered("SC00A","(")
$SC00B::Layered("SC00B",")")
$SC00C::Layered("SC00C","_")
$SC00D::Layered("SC00D","+")
; =================================
; ======== Top row ========
; =================================
$SC010::Layered("SC010", "Esc")
; Ctrl+Shift+Z on W
$SC011::
if GetKeyState("CapsLock", "T") = 1
Send {Blind}^+z
else if GetKeyState("CapsLock", "T") = 0
Send {Blind}{SC011}
return
$SC012::Layered("SC012", "Backspace")
$SC013::Layered("SC013", "Del")
$SC014::Layered("SC014", "Insert")
$SC015::Layered("SC015", "PgUp")
$SC016::Layered("SC016", "Home")
$SC017::Layered("SC017", "Up")
$SC018::Layered("SC018", "End")
; AltGr+P on P
$SC019::
if GetKeyState("CapsLock", "T") = 1
Send {Blind}{RAlt Down}p{RAlt Up}
else if GetKeyState("CapsLock", "T") = 0
Send {Blind}{SC019}
return
; =================================
; ======== Middle row ========
; =================================
$SC01E::LayeredControl("SC01E", "a")
$SC01F::Layered("SC01F", "AltDown")
$SC01F Up::Layered("SC01F Up", "AltUp")
$SC020::Layered("SC020","ShiftDown")
$SC020 Up::Layered("SC020 Up", "ShiftUp")
$SC021::Layered("SC021","CtrlDown")
$SC021 Up::Layered("SC021 Up", "CtrlUp")
$SC022::Layered("SC022","Tab")
$SC023::Layered("SC023","PgDn")
$SC024::Layered("SC024","Left")
$SC025::Layered("SC025","Down")
$SC026::Layered("SC026","Right")
$SC027::Noop("SC027")
$SC028::Noop("SC028")
; =================================
; ======== Bottom row ========
; =================================
$SC02B::Noop("SC02B")
$SC02C::LayeredControl("SC02C", "z")
$SC02D::LayeredControl("SC02D", "x")
$SC02E::LayeredControl("SC02E", "c")
$SC02F::LayeredControl("SC02F", "v")
$SC030::
if GetKeyState("CapsLock", "T") = 1
{
MouseClick, left
MouseClick, left
}
else if GetKeyState("CapsLock", "T") = 0
{
Send {Blind}{SC030}
}
return
$SC031::LayeredControl("SC031", "Space")
; Return on M key
$SC032::
if GetKeyState("CapsLock", "T") = 1
Send {Return}
else if GetKeyState("CapsLock", "T") = 0
Send {Blind}{SC032}
return
$SC033::Noop("SC033")
$SC034::Noop("SC034")
$SC035::Noop("SC035")
; =================================
; ======== Others ========
; =================================
; Return on Space key
$SC039::
if GetKeyState("CapsLock", "T") = 1
Send {Return}
else if GetKeyState("CapsLock", "T") = 0
Send {Blind}{SC039}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment