0

I have a special mouse button that serves as a double click. It doesn't have any special key, it's just sending two LButton signals.

I have introduced the #InstallMouseHook into my script to be able to track mouse clicks. I have gotten this after pressing the double button multiple times:

VK  SC  Type    Up/Dn   Elapsed Key     
---------------------------------------------------------------------------------------     
04  000     d   2.78    MButton         
04  000     u   0.19    MButton         
01  000     d   0.65    LButton         <- Manual DC     
01  000     u   0.17    LButton         
01  000     d   0.11    LButton         
01  000     u   0.14    LButton         
04  000     d   0.75    MButton         
04  000     u   0.19    MButton         
01  000     d   0.45    LButton         <- Special button DC            
01  000     u   0.00    LButton         
01  000     d   0.00    LButton         
01  000     u   0.00    LButton    

From what I assume The elapsed key is key to determining what is a double click (DC) by the DC mouse button and which one by me manually pressing left click two times. I want to remap the former scenario, not the latter (DC button::something else like middle click and my manual double left click to remain the same). So far it seems that the elapsed time for the DC button is <2.0 and manual DC >2.0.

The idea would be to have something like this (not in AHK language):

loop 
 if (LButton == 1) //pressed
    {
    t=StartElapseTimer;
    if (t<2 && LButton == 1) //how to check it went down and up before down the 2nd time?
       LButton::MButton; //the remapping I want
    else // t>2
       Nothing //let me do a regular DC
    }
end

Could you help me on how to start the timer and what environment variables need to be set?

Thanks.

JonesR
  • 9
  • 1
  • 3
  • I'm having a really hard time grasping what you're actually asking. Is it correct that you have some kind of special mouse button that generates double clicks and you want to remap this button? If yes, it would be great if you outlined these "special double clicks" in the above keylog, so that they can be told apart from normal (double) clicks. – MCL Dec 12 '13 at 15:35
  • Yes, that is exactly what I am trying to do. Added an intro paragraph to my question. – JonesR Dec 12 '13 at 17:04
  • These logged clicks are all produced by the special button? – MCL Dec 12 '13 at 17:06
  • Clarified in the keylog (all are from the special button except the last) – JonesR Dec 12 '13 at 17:07

1 Answers1

0

Upon each click, you have to check the elapsed time since the last click and decide how to handle the information:

dcTime := 50

LButton::
    if(A_PriorHotkey = A_ThisHotkey && A_TimeSincePriorHotkey < dcTime) {
        Send, {MButton}
    } else {
        Send, {LButton}
    }
return

Of course, you'll have to adjust the timeout according to your mouse button's speed. I also recommend calling SetBatchLines, -1 as it will minimize inaccuracies in time measurement.

MCL
  • 3,985
  • 3
  • 27
  • 39
  • I'm having difficulties to make this one work with the DC button (regular left mouse double click works perfectly with this). The DC button does not ever trigger the first if condition -unless I press left click and then DC button-. I changed your Send MButton line to 'MsgBox % A_TimeSincePriorHotkey' in order to verify the delay. Any ideas? I think it has to do with the zero delays in the DC button vs manual DC. I updated the initial keylog to clarify this: for the DC button there is 0.00 delay between the first LButton press and the second. – JonesR Dec 13 '13 at 07:46
  • @JonesR Try to just output `A_TimeSincePriorHotkey` (no conditions) when LButton is called. – MCL Dec 13 '13 at 07:49
  • I gave up. Your suggestion helped in determining the delay when double clicking manually or with the button. Problem is they are in the same range and even then the DC button never triggered the script. Ended up remapping my right button to MButton (my initial intention was to use it only in chrome/firefox to open links instead of Control+Click or MButton). Your solution is as close as it gets. Thanks. – JonesR Dec 13 '13 at 14:40