Skip to content

Instantly share code, notes, and snippets.

@sriramkswamy
Last active January 9, 2023 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sriramkswamy/55afcc7802a045432fcc81f662e4405e to your computer and use it in GitHub Desktop.
Save sriramkswamy/55afcc7802a045432fcc81f662e4405e to your computer and use it in GitHub Desktop.
Windows AutoHotKey script for some shotrcuts
;; Change the basic layout of the keyboard a little bit
; Use just the Home key for Win Tab
Home::#Tab
; Use the End key to quit programs
End::!F4
; Switch between virtual desktops with Page Up and Page Down
PgUp::#^Left
PgDn::#^Right
; Primary helper function to set and unset timers
RemoveTooltip(){
SetTimer, RemoveTooltip, Off
Tooltip
return
}
; Map Capslock to Control when held and launcher when pressed
; Map press & release of Capslock with no other key to Alt + Space (shortcut for launcher)
*Capslock::
Send {Blind}{LControl down}
return
*Capslock up::
Send {Blind}{LControl up}
; Tooltip, %A_PRIORKEY%
; SetTimer, RemoveTooltip, 1000
if A_PRIORKEY = CapsLock
{
Send {LAlt down}{Space}{LAlt up}
}
return
; Modify LShift to send Ctrl Shift Tab when pressed and LShift when held
*LShift::
Send {Blind}{LShift down}
return
*LShift up::
Send {Blind}{LShift up}
; Tooltip, %A_PRIORKEY%
; SetTimer, RemoveTooltip, 1000
if A_PRIORKEY = LShift
{
Send {LCtrl down}{LShift down}{Tab}{LShift up}{LCtrl up}
}
return
; Modify RShift to send Ctrl Shift Tab when pressed and RShift when held
*RShift::
Send {Blind}{RShift down}
return
*RShift up::
Send {Blind}{RShift up}
; Tooltip, %A_PRIORKEY%
; SetTimer, RemoveTooltip, 1000
if A_PRIORKEY = RShift
{
Send {RCtrl down}{Tab}{RCtrl up}
}
return
; Press both shift keys together to toggle Capslock
ToggleCaps(){
; this is needed because by default, AHK turns CapsLock off before doing Send
SetStoreCapsLockMode, Off
Send {CapsLock}
SetStoreCapsLockMode, On
return
}
LShift & RShift::ToggleCaps()
RShift & LShift::ToggleCaps()
;; Some straight up shortcut keys
; left alt and h,j,k,l for arrow keys
!j::SendInput, {Down}
!k::SendInput, {Up}
!l::SendInput, {Right}
!h::SendInput, {Left}
; move to the end of the line and the start of the line
!a::SendInput, {Home}
!e::SendInput, {End}
; delete line in different ways
!d::SendInput, {Home}{LShift down}{End}{LShift up}{BackSpace}
; move by words
!f::SendInput, {LCtrl down}{Right}{LCtrl up}
!b::SendInput, {LCtrl down}{Left}{LCtrl up}
; delete the previous word
!w::SendInput, {LCtrl down}{LShift down}{Left}{LShift up}{LCtrl up}{BackSpace}
; i, o for window snapping
!i::Send, {LWin down}{Left}{LWin up}
!o::Send, {LWin down}{Right}{LWin up}
; m, p for minimizing and maximizing
!m::Send, {LWin down}{Down}{LWin up}
!p::Send, {LWin down}{Up}{LWin up}
; u, n to close or add a new virtual desktop
!u::Send, {LWin down}{LCtrl down}{F4}{LCtrl up}{LWin up}
!n::Send, {LWin down}{LCtrl down}{d}{LCtrl up}{LWin up}
; send window to left or right monitors
LWin & j::Send, {LWin down}{LShift down}{Left}{LShift up}{LWin up}
LWin & k::Send, {LWin down}{LShift down}{Right}{LShift up}{LWin up}
; reload the configuration
<!r::Send, {Reload}
; just the apps key or the numpad enter for notifications
AppsKey::#a
Insert::#a
; Change Numpad keys when NumLock is off
NumpadEnter::#a
NumpadIns::RWin
NumpadDel::PrintScreen
NumpadHome::#Tab
NumpadEnd::!F4
NumpadPgUp::#^Left
NumpadPgDn::#^Right
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment