Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Capture Modifier Key "pump" or "double tap"

$
0
0
First of all, this is not for a game, I want to hook this event to "Start Window Switcher".
 
 I am trying to create a script that will capture a left shift double press (pump) such that it only works when no other keys have also been pressed.
I know this is conceptually possible with _IsPressed(), but I am worried about execution speed and having to make calls to _IsPressed() for each key.

So, in English-ish:


The key I am talking about is the left shift key...
If I have pressed and released the key twice, and no other keys intervene or occur at the same time...
and If the first press and release was less than a half second long...
and If the second press down comes withing a half second of the first release...
and If the second press and release was less than a half second long...
Then Do something wonderful!


My Issues:
  • The While Loop logic of this makes my brain hurt a bit, so help is welcome but I can probably figure it out...eventually
  • Is there a way to avoid the brute force call to _IsPressed() for every key? (Do we have a GetAsynch dll call that gets entire keyboard?)
  • Additionally, playing with _IsPressed() for right mouse button shows indeterminate or no-op behavior for me
AutoIt         
;starter code -- not working, plus does not take into account other keys #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") Local $tim0; Local $tim; Local $first=False; Local $firstup=False; Local $secup=False; Local $max=500 While 1   If $first Then     If _IsPressed('A0',$hDLL) Then       If $firstup Then         Local $r=TimerDiff($tim)         If $r<$max Then           ;Yay!           $first=False           $firstup=False           $secup=True           ;ToolTip("Succeed")           ;Beep(1500,20)         Else           ;took too long           $first=False           $secup=False           $firstup=False           ;ToolTip("Fail second too long")           ;Beep($max,20)         EndIf       Else         ;firstup false       EndIf     Else       ;first and not pressed       If $firstup==False Then         $firstup=True         $secup=False       Else         Local $r=TimerDiff($tim)         If $r>$max Then           ;took to long           $first=False           $firstup=False           ;ToolTip("Fail second too long 2")           ;Beep($max,20)         EndIf       EndIf     EndIf   Else     If _IsPressed('A0',$hDLL) Then       $tim=TimerInit()       $firstup=False       $first=True     Else       ;not first not pressed       If $secup Then        ToolTip("Succeed")         $first=False         $secup=False         $firstup=False       EndIf       ;do nothing     EndIf   EndIf WEnd

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>