Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Double-Click keypresses as Triggers rather than mouse clicks
#1
Hi,
It seems like this is not already part of QM. There is "optional follow by" but this doesn't allow you to have both single and double keypresses as separate triggers.

This is actually important since many devices need to map keyboard sequences for their extra "mouse buttons" e.g. if you want a trigger to be double click mouse button 6 (mapped to Ctrl-Alt-1), you would need to have someway for QM to distinguish between CA1 clicked twice in fast succession and single press.

Looking at the code for mouse-chords (which already contains functionality for double clicking the triggering key), this seems like it should be possible to convert this code to that. But I wouldn't know how to do it without losing the ability to distinguish between single and double (and perhaps triple?) clicks (actually keypresses).

Don't want to make extra work for you Gintaras, just want to see what you think...or if there is an answer already out there that I couldn't find...
Thanks,
Stuart
#2
Code:
Copy      Help
int+ __time1 ;;time of previous trigger
int timenow=GetTickCount
int timediff=timenow-__time1
__time1=timenow

if(timediff<500) ;;0.5 s
,__time1=0
,out "double"
else
,out "single"
#3
Hi Gintaras,

Thanks for quick response.

This seems to recognize single and double clicks separately but when it recognises the double click it also sends out the single click "single" statement.

Stuart
#4
I think you want to use both triggers - on single click and on double click. But you can use only one of them. Because, when you click first time, computer does not know if you will click second time soon.
#5
If the first click triggers and then there is no second depression of the same key in a certain small amount of time, the final result is a single-click trigger, whereas if there is a second same-keystroke in that time, a double-click trigger occurs.
I will look at the code you gave and see if I can modify it to this...(or maybe I didn't set up the triggers right in the code you posted....)
I'll post any good results,

Stuart
#6
Code:
Copy      Help
int timefirstclick=GetTickCount
wait 0.4 KF u
err
,mes "single click"
int timesecondclick=GetTickCount
int timediff=timesecondclick-timefirstclick
out timediff
if(timediff<400)
,mes "double click"
,ret

The funny thing about this is that I was at first having trouble with the syntax for the trigger
In this case the letter "u"
U is alright as a test trigger but shouldn't work in real usage because you often have to type it for real! The extra keys on mice are usually some Ctrl-key or Alt-key combination like Ctrl-U.

As far as I know, you can't use a combination in the wait statement -

Code:
Copy      Help
wait 0.5 KF Cu

Doesn't work to indicate that you should wait until the combination Ctrl-U is lifted.

but if there is a way, I would love to know!

Anyway, I set the trigger to this to be Ctrl-U in QM - and set the side-mouse button (4) to be Ctrl-U using it's assignment program (Microsoft Intellimouse).

Anyway, the funny thing is that it worked!
The second "u", even though it was being sent along with a Ctrl key (from the mouse assignment), still was enough to set off the wait statement and therefore differentiate indicate a double click...

Amazing.

Let me know if this will be robust (am I missing the fatal flaw?) but it seems to be working.

Stuart

ps. this is exciting because it should allow triple clicks as well

Here goes:
Code:
Copy      Help
int timefirstclick=GetTickCount
wait 0.4 KF u
err
,mes "single click"
,ret


int timesecondclick=GetTickCount
wait 0.4 KF u
err
,mes "double click"
,ret
int timethirdclick=GetTickCount
int timediff=timesecondclick-timefirstclick
int timediff2=timethirdclick-timefirstclick
;out timediff
if(timediff<800)
,mes "triple click"
,ret
#7
Works well. Single clicks delays 0.4 s but this is acceptable in most cases.


Forum Jump:


Users browsing this thread: 1 Guest(s)