I have this code so far using autohotkey (.ahk)


which correctly maps my arrow keys to j,k,l,æ accordingly. (æ is the ; key button on english keyboards)

This works like a charm except for the fact that I can't hold "ctrl+alt+j" for intance, to go to next word to the left as I do if I'm using "ctrl+arrowKeyLeft".

I need this to work with shift as well, to highlight the letters to the left. What happens now is simply nothing so I guess I'm supposed to tell the script that it should highlight text on "shift+alt+(j,k,l,æ)" somehow but I haven't been able to find a way to do this just yet. Any help, likes or suggestions on how to do this is very appreciated. Thanks in advance.

  • I'm not sure of a good straightforward answer other than duplicating those lines with ctrl and shift added. Normally what you describe is undesirable - most people want ctrl+shift+Q to do something different than ctrl+(shift+Q) or shift+(ctrl+Q). – NextInLine Feb 9 '15 at 21:39
  • @NextInLine so something like: ^!j::SendInput,{CTRL+LEFT} I guess? – Peterrr Feb 10 '15 at 8:44
  • Something like that. I can't get to AutoHotKey's site right now to check their docs. – NextInLine Feb 10 '15 at 17:38

Following the line of thought in @NextInLine's comment, something like the below could be a starting point, but it seems that there's some funny business going on with Windows and these key combinations, so the current script is acting like a whole line selection instead of per-word. Perhaps testing on your system will result in different behavior.

Basically the script does as follows:

  1. Check that the key state of Ctrl and Alt is True (pressed down).
  2. If true, Loop the included code 20 times
  3. Inside Loop, wait for j to be pressed for 2 seconds. If pressed, perform {Alt up}{Ctrl down}{Shift down}{LEFT}
  4. Break loop if no j key is detected.

The code:

      if (GetKeyState("Ctrl", "P")) AND (GetKeyState("Alt", "P"))
        Loop, 20
        KeyWait, j, D T2
        if (GetKeyState("j", "P"))
          SendInput, {Alt up}{Ctrl down}{Shift down}{LEFT}
      SendInput, {Ctrl up}{Shift up}

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.