Question

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.

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top