At work I have a Windows PC. I don’t have much personal experience with Windows which is why I am asking.
I want to remap the caps lock key to function as a control key. Ideally, on a per-user basis as sometimes other people use the workstation and I don’t want to confuse them.
-
Was able to install Auto Hot Key. A test script worked. However I couldn’t find working instructions about how to do this specific remapping. Example scripts I found seem to have some conflict between v1 and v2 of AH.
-
I don’t have admin access however I could probably ask for something, but it would have to work immediately without a lot of fooling around. I will not be granted admin access to try a bunch of things til I find something that works.
What’s the best way?
Okay, so make a script, name it whatever you feel like and paste this:
; The keyboard hook must be installed.
InstallKeybdHook
SendSuppressedKeyUp(key) {
DllCall("keybd_event"
, "char", GetKeyVK(key)
, "char", GetKeySC(key)
, "uint", KEYEVENTF_KEYUP := 0x2
, "uptr", KEY_BLOCK_THIS := 0xFFC3D450)
}
; Disable Alt+key shortcuts for the IME.
~LAlt::SendSuppressedKeyUp "LAlt"
; Test hotkey:
!CapsLock::MsgBox A_ThisHotkey
; Remap CapsLock to LCtrl in a way compatible with IME.
*CapsLock::
{
Send "{Blind}{LCtrl DownR}"
SendSuppressedKeyUp "LCtrl"
}
*CapsLock up::
{
Send "{Blind}{LCtrl Up}"
}
Save it, run it and you should be good to go.
edit: This is V2, just in case.
Thanks I will do this!
Does this first line mean anything? I didn’t install anything except the basic AH package:
;The keyboard hook must be installed.
It is just a comment for the InstallKeybdHook command just bellow it, as it is crucial for this magical code (that I don’t fully grasp yet) to work.
But it does.