Search code examples
autohotkeyarrow-keyswindows-key

Map Windows + JILK to Arrow keys using AutoHotKey?


I can't seem to find how to bind X + Y => Z. Most links online show how to do the opposite. I'm trying to achieve this mapping:

RWin + j :: Left
RWin + l :: Right
RWin + i :: Up
RWin + k :: Down

I tried this syntax RWin&l::Right but it didn't compile.

Any ideas?

Edit: I'd also want it to play nice with the other modifier keys. So that when I press RWin+j and then shift it sends a shift+left (and same with ctrl and alt)

Edit: Thanks to @AleOtero93 here's what I have so far:

; Arrows
>#j::Send,{LEFT}
>#l::Send,{RIGHT}
>#i::Send,{UP}
>#k::Send,{DOWN}

; Shift modifier
>#+j::Send,+{LEFT}
>#+l::Send,+{RIGHT}
>#+i::Send,+{UP}
>#+k::Send,+{DOWN}

; Ctrl modifier
>#^j::Send,^{LEFT}
>#^l::Send,^{RIGHT}
>#^i::Send,^{UP}
>#^k::Send,^{DOWN}

; Ctrl+Shift
>#^+j::Send,^+{LEFT}
>#^+l::Send,^+{RIGHT}
>#^+i::Send,^+{UP}
>#^+k::Send,^+{DOWN}

; Alt modifier
>#!j::Send,!{LEFT}
>#!l::Send,!{RIGHT}
>#!i::Send,!{UP}
>#!k::Send,!{DOWN}

; Alt+Ctrl
>#^!j::Send,^!{LEFT}
>#^!l::Send,^!{RIGHT}
>#^!i::Send,^!{UP}
>#^!k::Send,^!{DOWN}

; Alt+Shift
>#!+j::Send,!+{LEFT}
>#!+l::Send,!+{RIGHT}
>#!+i::Send,!+{UP}
>#!+k::Send,!+{DOWN}

; Alt+Ctrl+Shift
>#!^+j::Send,!^+{LEFT}
>#!^+l::Send,!^+{RIGHT}
>#!^+i::Send,!^+{UP}
>#!^+k::Send,!^+{DOWN}

; Insert/Delete
>#q::Send,{Insert}
>#a::Send,{Delete}

; Ctrl+Insert/Delete
>#^q::Send,^{Insert}
>#^a::Send,^{Delete}

; Shift+Insert/Delete
>#+q::Send,+{Insert}
>#+a::Send,+{Delete}

; Home/End
>#w::Send,{Home}
>#s::Send,{End}

; Ctrl+Home/End
>#^w::Send,^{Home}
>#^s::Send,^{End}

; Shift+Home/End
>#+w::Send,+{Home}
>#+s::Send,+{End}

; Ctrl+Shift+Home/End
>#^+w::Send,^+{Home}
>#^+s::Send,^+{End}

; PageUp/PageDown
>#e::Send,{PgUp}
>#d::Send,{PgDn}

; Ctrl+PageUp/PageDown
>#^e::Send,^{PgUp}
>#^d::Send,^{PgDn}

; Shift+PageUp/PageDown
>#+e::Send,+{PgUp}
>#+d::Send,+{PgDn}

; Escape
>#CapsLock::Send,{Escape}

I had to disable Win+L which can be done via registry (or a map #l::return? not tested) I'd be interested to know if somebody has a better solution without having to remap modifier keys.


Solution

  • I managed to work this out:

    >#j:: SendInput,{LEFT}
    >#l:: SendInput,{RIGHT}
    >#i:: SendInput,{UP}
    >#k:: SendInput,{DOWN}
    

    >: In modifier keys (suchs as Alt, Shift...) allow only the right one of them. (Use < for the left one)

    #: Shortcut of Win in AHK.

    And after the hotkey you are wanting to use, no spaces, use immediately :

    Also, + is shortcut for shift key.

    And in AHK & is only required for not modifier keys (like a & k), for shift, alt, etc. there is no need of &

    After that, giving a read to AutoHotkey help, I find out that you also need to override the Win+arrow, so you add this:

    >#left:: return
    >#right:: return
    >#up:: return
    >#down:: return
    

    Also, if disabling that Win shortcuts if what you want, make this change to the registry:

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
    NoWinKeys REG_DWORD 0x00000001 (1)
    

    But keep this in mind, Win+L and Win+U can not be overriden, according to AHK help. Hope someone solve that.