Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
Last active September 18, 2018 20:09
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 RichardBronosky/33943294de84192ecc7e89243f8fdfec to your computer and use it in GitHub Desktop.
Save RichardBronosky/33943294de84192ecc7e89243f8fdfec to your computer and use it in GitHub Desktop.
My basic Auto Hotkey script (for non-QMK keyboards)
;;;; Standard boiler plate
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Persistent
#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.
/*
;;;; Debugging: view key events
#InstallKeybdHook
#Persistent
KeyHistory
*/
;;;; Cheat sheet
; ^ ctrl
; ! alt
; + shift
; < Use the left key of the pair. e.g. <!a is the same as !a except that only the left Alt key will trigger it.
; > Use the right key of the pair.
; https://autohotkey.com/docs/Hotkeys.htm#Symbols
;;;; If the script is not elevated, relaunch as administrator and kill current instance:
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
try ; leads to having the script re-launching itself as administrator
{
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
;;;; Swap Ctrl and Alt
LAlt::Ctrl
LCtrl::LAlt
;;;; Make CapsLock Ctrl
SetCapsLockState, AlwaysOff
CapsLock::Ctrl
;;;; Make Win Key + Capslock work like Capslock (in case it's ever needed)
#Capslock::
If GetKeyState("CapsLock", "T") = 1
SetCapsLockState, AlwaysOff
Else
SetCapsLockState, AlwaysOn
Return
;;;; Sleep
#F12::
; Sleep/Suspend:
DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
; Hibernate:
;DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0)
Return
;;;; Activate screen saver
#s::
KeyWait, 3, L
KeyWait, LWin, L
RegRead, ScreenS, HKEY_CURRENT_USER,Control Panel\Desktop\,SCRNSAVE.EXE
RunWait,%ScreenS% /S
Return
;;;; Send special character
+!0::Send, °
+!.::Send, …
!Up::Send, 👆
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment