Last active
August 25, 2022 08:17
-
-
Save VirgilMing/c82bde8d79f6b9f85c3a6a64ac420f62 to your computer and use it in GitHub Desktop.
AHK script to swap keys on certain keyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Requires AutoHotInterception: https://github.com/evilC/AutoHotInterception | |
; Follow setup section | |
; Swaps leftctrl and capslock; escape and grave | |
#SingleInstance force | |
#Persistent | |
#include <AutoHotInterception> ; assumes libs already copied to AHK lib | |
; location, to allow execution in any location | |
global AHI := new AutoHotInterception() | |
global kID := AHI.GetKeyboardIdFromHandle("ACPI\VEN_LEN&DEV_0071") | |
; this is copied from AHI monitor | |
AHI.SubscribeKey(kID, GetKeySC("CapsLock"), true, Func("Caps_To_LCtrl")) | |
AHI.SubscribeKey(kID, GetKeySC("LControl"), true, Func("LCtrl_To_Caps")) | |
AHI.SubscribeKey(kID, GetKeySC("Escape"), true, Func("Esc_to_Grave")) | |
AHI.SubscribeKey(kID, GetKeySC("~"), true, Func("Grave_to_Esc")) | |
return | |
Caps_To_LCtrl(state){ | |
AHI.SendKeyEvent(kID, GetKeySC("LControl"), state) | |
return | |
} | |
LCtrl_To_Caps(state){ | |
AHI.SendKeyEvent(kID, GetKeySC("CapsLock"), state) | |
return | |
} | |
Esc_to_Grave(state){ | |
AHI.SendKeyEvent(kID, GetKeySC("~"), state) | |
return | |
} | |
Grave_to_Esc(state){ | |
AHI.SendKeyEvent(kID, GetKeySC("Escape"), state) | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment