Click detect
Return.are you TRYING to avoid my function?.it does EXACTLY what you need, reliably.Our event listener stops working. Do you want F5 only on single or on single & double? You need to include the functions from HotkeyDispatcher-Example.ahk (not the whole file) Is there anyway to clean it up a bit?.yes. So the above script sends f5 when you tap x once, and sends f6 if you tap it twice.no, it appears to Send F5 if you press x once & Send F5 & F6 if you press x twice.F5 is sent unconditionally.
#CLICK DETECT CODE#
(looking for any way to clean it up).is there something wrong with my script? The 1st version did keyboard keys & the new version does mouse clicks too.your code only does x & would need copy/pasted a hundred times to handle other keys. If (rHeldLast < 350 & A_TickCount - rUpLast < 350) Need to keep track of three variables per key (what a pain) Like I said, it is a royal pain in the ass to have to do this for EVERY button/key, and thats why I am here looking for a better way! And two, the one "A_TimeSincePriorHotkey" is shared among ALL hotkeys, so if you hit two DIFFERENT hotkeys close together, it may mistakenly trigger a double click. For one, it doesnt check to see if you actually clicked/tapped the button/key previously (in otherwords, you can simply HOLD the button/key to fake a double click, which is NOT what I want). The "A_TimeSincePriorHotkey" is close to what I am looking for, however, it has a few problems. LButton::HotkeyDispatcher(DoublePress_ms, Held_ms).but as I said, in my limited testing, it didn't work, I will be trying to fix that.Īlso, instead of reading my code & going "Guh?", please download/run it & press the keys in the example: F7, F8, F9 & F10.try pressing them once & waiting, then try hitting them faster & also try holding them down. Please give me an exact example of what you want to work, so next time I can really be sure my script does what you are asking.Īlso, FYI, my script is supposed to handle double clicks, like any other Hotkey. If you look at my code again, ignoring that it doesn't seem to handle "double clicking" yet, it really is pretty good at detecting single, double & held keypresses (which is part of what you are asking for, right?). They just call the same function (& if you don't want to handle all of those events, simple delete the labels of the events you don't need & the script will ignore that event).Ĭan anyone else confirm.I don't even think I understand what way you are expecting to handle this, could you write some pseudo-code? I don't understand the approach you want to use.Arrays? No, AutoHotkey don't have "real Arrays" yet, it does have "fake Arrays" tho, but I don't know how that applies (why do you need Arrays for this? ). If you look at my examples, you can see the script handles single, double & held keypresses of F7, F8, F9 & F10.those are just examples tho & you can easily add/remove Hotkeys, without pasting the code many times. I like to write things so you can use it multiple times & not paste the code again, doing that requires code/framework to set-up. It even includes an example.Īgain, I never said it was the "easiest" way, as None showed, you CAN achieve some things in less code, but you'd need to paste that code for EVERY Hotkey. In any case, I think it is a good framework for detecting single, double & held Keyboard-key presses (that works flawlessly). I will try to see if it can handle double clicks (by that I mean Mouse, not KB), later. My script WILL handle double-pressing Keyboard keys & it was supposed to handle double clicking, but that was an after-thought, after I wrote the script.& when I did a little testing, it didn't seem to work. but didnt see anything about double clicking.you say "double click" then mention "a key twice in a row".double click, to me, means the mouse, but pressing "a key twice in a row" would be a double press. double click, or tapped a key twice in a row?