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?

link|improve this question

80% accept rate
feedback

1 Answer

up vote 3 down vote accepted
~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 :)

link|improve this answer
Here's the problem: I'm trying to emulate the behavior of win+tab (keep down windows key so that the filp3d view doesn't go away), so that i can ctrl+scroll to wintab. – RCIX Sep 5 '09 at 2:28
right, well the function getkeystate("key") can be used to give hotkeys conditional meanings, I'll edit the post so I have codetags – Phoshi Sep 5 '09 at 11:10
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.