Home » Questions » Computers [ Ask a new question ]

How to set a hotkey only when another one is active

How to set a hotkey only when another one is active

I want to make a hotkey that only exists while another key is pressed. Ordinarily, just using modifiers would work but i need to intercept specific keys while one is down so that the keys work in normal use. How do i do that?

Asked by: Guest | Views: 186
Total answers/comments: 1
Guest [Entry]

"~l & b::Send R

Sends R when l and b is pressed (though you'd probably want to add a {backspace} to remove the l, if you wanted such a thing for some reason)

It's the ~ that tells AHK ""Don't overwrite whatever this does at the moment"" that's important.

edit: GetKeyState:

r::
if getkeystate(""q"")
{
Send, Q and R Party YEAH!
}
else
send r
return

would fire off a lovely string if r and q are pressed. The upshot of this is you can have as many ifs as you like :)"