Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a key combination written as ~XButton1 & XButton2::. When I press the combination, the XButton1 event isn't filtered out. This can cause, for example, my browser to go back a page when I don't want it to.

According to the docs, removing the ~ will cause the keys not to be passed on to the rest of the system. When I do that, however, XButton1 is never passed to the system, whether I finish the combo or not.

Here's the behavior I'd like to see:

AHk should buffer the first XButton1 event when it's recieved. If I do press XButton2, pass on nothing to the system. But, if I don't press XButton2, send a quick XButton1 down-and-up.

Is there any way to get this behavior?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

As explained in the AutoHotkey documentation about the &, using the a & b pattern causes the a key to lose its original function. To make the a key work on release when it's used alone, you can make a hotkey that maps back to itself like a::Send {a}.

In your case, you might try something like

XButton1 & XButton2:: whatever you want
XButton1::Send {XButton1}

share|improve this answer
    
This was it. I'm not sure how I missed that section. Thanks! –  zildjohn01 Aug 24 '10 at 17:47

You should try playing with the KeyWait function and the A_PriorHotKey and A_TimeSincePriorHotkey variables, as explained in the example #4 of the KeyWait documentation.

; Example #4: Detects when a key has been double-pressed (similar to double-click).
; KeyWait is used to stop the keyboard's auto-repeat feature from creating an unwanted
; double-press when you hold down the RControl key to modify another key.  It does this by
; keeping the hotkey's thread running, which blocks the auto-repeats by relying upon
; #MaxThreadsPerHotkey being at its default setting of 1.
; Note: There is a more elaborate script to distinguish between single, double, and
; triple-presses at the bottom of the SetTimer page.

~RControl::
if (A_PriorHotkey <> "~RControl" or A_TimeSincePriorHotkey > 400)
{
    ; Too much time between presses, so this isn't a double-press.
    KeyWait, RControl
    return
}
MsgBox You double-pressed the right control key.
return
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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