0
votes

I need to use hotkeys like [Ctrl + 9 + 8], or [Ctrl + A + B].

Autohotkey documentation here says that combinations of three or more keys are not supported. However [Alt + Ctrl + Shift + X] modifier key combinations are supported, where X can be an alphanumeric character.

2

2 Answers

3
votes

KeyWaiting is showed in the other answer, I'd like to show the other option, which is using #If.
You create a context sensitive hotkey by setting whatever condition with the #If directive.
In your case you'd want to check if the first key(s) of your hotkey is/are held down.
And then you'd set the last keys as a hotkey.

#If, GetKeyState("Ctrl") ;start of context sensitive hotkeys
8 & 9::
    MsgBox, % "Ctrl + 8 + 9 held down"
return
#If ;end of context sensitive hotkeys 

;example of holding down even more keys
;is only going to work if your system can
;recognize this many keys at once
#If, GetKeyState("Ctrl") && GetKeyState("1") && GetKeyState("2") && GetKeyState("3") && GetKeyState("4") && GetKeyState("5")
6 & 7::
    MsgBox, % "Ctrl + 1 + 2 + 3 + 4 + 5 + 6 + 7 held down"
return
#If

Whether or not I'd recommend this approach is another thing.
If your script is just about simple hotkeys or something like that, this is a very good approach.
But if your script is more complex than that, you might run into the problems #If can cause. More about that from the documentation.
Basically, just try it out and if you have problems, maybe consider another approach.

1
votes

There are different workaround to do this. The following script uses KeyWait to handle multiple keys. Script for handling the hotkey needs be placed inside the If block.

;Script to handle multiple key combinations ;Press Ctrl first then 9 and 8 in correct order for this to work
^9:: 
    KeyWait, 8, D T3 
    ;KeyWait, 7 D T3 ;add if more combinations are required
    if (ErrorLevel = 0)
    {
        MsgBox, [Ctrl + 98] key combination recognized ; script to handle the hotkey to be placed here
    }
return