1

I'm migrating my mac workflow to Windows. One thing I couldn't live without is hyper key which is combination of Ctrl + Option + Shift + Cmd. I use Karabiner app to remap Capslock to this Hyper key. I have heard that Autohotkey is an Karabiner alternative for Windows. Could you guys please help me to emulate this feature in Windows.

My ideal result is:

  • Deactivate Capslock completely because I rarely use this
  • Toggle Capslock will perform ESC key
  • Hold down Capslock will perform Ctrl + Alt + Shift + Windows. For example Capslock + C will be Ctrl+Alt+Shift+Windows+C

Many thanks in advance!

In the attempt of solving my problem, I wrote some lines of code but it doesn't work at all. Please help me point out my mistake:

;-----------------------------------------
; hyper key for windows
;=========================================

; --------------------------------------------------------------
; notes
; --------------------------------------------------------------
; ! = alt
; ^ = ctrl
; + = shift
; # = lwin|rwin
;
#NoEnv ; recommended for performance and compatibility with future autohotkey releases.
#UseHook
#InstallKeybdHook
#SingleInstance force

SendMode Input

;; deactivate capslock completely
SetCapslockState, AlwaysOff

;; remap capslock to hyper
;; if capslock is toggled, remap it to esc

Capslock::
    SendInput {Ctrl Down}{Alt Down}{Shift Down}{LWin Down}
    KeyWait, Capslock
    SendInput {Ctrl Up}{Alt Up}{Shift Up}{LWin Up}
    if (A_PriorKey = "Capslock") {
        SendInput {Esc}
    }
return

;; vim navigation with hyper
~^!+#h:: SendInput {Left}
~^!+#l:: SendInput {Right}
~^!+#k:: SendInput {Up}
~^!+#j:: SendInput {Down}

;; popular hotkeys with hyper
~^!+<#c:: SendInput ^{c}
~^!+<#v:: SendInput ^{v}

Result:

  • Toggle Capslock performs ESC
  • Hold Capslock performs Ctrl+Alt+Shift+Win key combination
  • Hold Ctrl+Alt+Shift+Win with h,j,k,l,c,v works as expected
  • However Hold Capslock with h,j,k,l,c,v doesn't work
2
  • Did you try to write a Autohotkey script for this? – Seth Nov 5 '16 at 8:01
  • @Seth not at the moment as I'm trying to read through Autohotkey docs. I'm trying to make my first script by tmr. I hope someone who got great knowledge of Autohotkey script would help me resolve my problem quicker. – babygau Nov 5 '16 at 8:06
3

Thanks for anyone trying to help me, I figured out the prob on my own and would like to share it in case anyone comes across this prob.

#NoEnv ; recommended for performance and compatibility with future autohotkey releases.
#UseHook
#InstallKeybdHook
#SingleInstance force

SendMode Input

;; deactivate capslock completely
SetCapslockState, AlwaysOff

;; remap capslock to hyper
;; if capslock is toggled, remap it to esc

;; note: must use tidle prefix to fire hotkey once it is pressed
;; not until the hotkey is released
~Capslock::
    ;; must use downtemp to emulate hyper key, you cannot use down in this case 
    ;; according to http://bit.ly/2fLyHHI, downtemp is as same as down except for ctrl/alt/shift/win keys
    ;; in those cases, downtemp tells subsequent sends that the key is not permanently down, and may be 
    ;; released whenever a keystroke calls for it.
    ;; for example, Send {Ctrl Downtemp} followed later by Send {Left} would produce a normal {Left}
    ;; keystroke, not a Ctrl{Left} keystroke
    Send {Ctrl DownTemp}{Shift DownTemp}{Alt DownTemp}{LWin DownTemp}
    KeyWait, Capslock
    Send {Ctrl Up}{Shift Up}{Alt Up}{LWin Up}
    if (A_PriorKey = "Capslock") {
        Send {Esc}
    }
return

;; vim navigation with hyper
~Capslock & h:: Send {Left}
~Capslock & l:: Send {Right}
~Capslock & k:: Send {Up}
~Capslock & j:: Send {Down}

;; popular hotkeys with hyper
~Capslock & c:: Send ^{c}
~Capslock & v:: Send ^{v}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.