Jimmy Man Jin Hay
Jimmy Man Jin Hay

Reputation: 29

Autohotkey remapping alt+j to left but alt+shift+j doesn't select left nor do alt+ctr+j move a caret , if getKeyState does not work

Basically,

It's inspired by Vim I want to use a key(e.g Alt, F1) combination(+I J K L) to map to Arrow Keys

What is already done in Autohotkey

Ralt & j::send{Left}
Ralt & k::send{Right}

... Now I take Alt+I as up etc,which is pretty fine for me But the problem comes when you press

Ralt+Shift+j  (Suppose to select the last charater)
Ralt+Ctrl+j   (Suppose to move a caramel text)

These kind of combination would not work and it just get overrided to basic move cursor to left

Even if I use if/while statement with GetKeyState, it doesn't gonna work

if GetKeyState("Shift","P")
   Ralt+j::send +{Left}
This kind of stuff didn't work

Any Ideas on that ?It would make coding very efficient without having to move the right hand.

Thanks in advance.

Upvotes: 2

Views: 1074

Answers (1)

Elliot DeNolf
Elliot DeNolf

Reputation: 2999

You are missing 2 things:

  1. Must use a # symbol when doing a context sensitive hotkey
  2. The bottom section of code is using a + instead of the & you used previously.

See the below modification:

RAlt & j:: Send {Left}
RAlt & k:: Send {Right}

#If GetKeyState("Shift","P")
   RAlt & j:: Send +{Left}
   RAlt & k:: Send +{Right}

; Close with #If to remove the context or simply start another '#If GetKeystate ....'

Upvotes: 3

Related Questions