obd Posted May 10, 2008 Posted May 10, 2008 I need to measure the interval between key up and key down. I tried to do it with 2 hotkeysets ( {key down}/{key up}) pointing to 2 different functions. HotKeySet, however, seems not to work with {key down}/{key up} as hotkeys, so any suggestions what should I fo?
rawrr Posted May 10, 2008 Posted May 10, 2008 (edited) EDIT : Nvm didn't really understand what you said, you do Hotkeyset ("{UP}","Upkey") For up. Hotkeyset ("{Down}","Downkey) For down. Edited May 10, 2008 by rawrr
obd Posted May 10, 2008 Author Posted May 10, 2008 (edited) This is like really experimental (just to see how things work) and written on the small hours, that's why I prefered to rather describe the problem. I didn't even take time to think whether this acctually measures time or not, before I ran into this hotkeyset problem -And rawrr, I didn't mean the arrow keys, I meant any key. To measure the time the key was held down. expandcollapse popupHotKeySet("{F11}", "test2") HotKeySet("{a down}", "ad") HotKeySet("{a up}", "au") HotKeySet("{d down}", "dd") HotKeySet("{d up}", "du") Global $roska Global $dif Func test2() Send ("{w down}") Global $begin = TimerInit() HotKeySet("{F11}", "stop") EndFunc Func ad() InputBox ( "title", "Prompt", $roska) $dif = Round(TimerDiff($begin)) $roska = $roska & $dif & " a(" Endfunc Func au() $roska = $roska & Round(TimerDiff($begin)) - $dif & ") " $begin = TimerInit() Endfunc Func dd() $dif = Round(TimerDiff($begin)) $roska = $roska & $dif & " d(" Endfunc Func du() $roska = $roska & Round(TimerDiff($begin)) - $dif & ") " $begin = TimerInit() Endfunc Func stop() $roska = $roska & TimerDiff($begin) Send ("{w up}") InputBox ( "title", "Prompt", $roska) HotKeySet("{F11}", "test2") $roska = "" $dif = "" EndFunc Sleep(10000) While 1 = 1 Wend Edited May 10, 2008 by obd
Generator Posted May 11, 2008 Posted May 11, 2008 Something like...Tested #include<Misc.au3> If _IsPressed("01") Then $Timer=TimerInit() While _IsPressed("01") Sleep(1) WEnd $Time=Round(TimerDiff($Timer)) MsgBox(0,"Time(ms) button held",$Time) EndIf
nfwu Posted May 11, 2008 Posted May 11, 2008 HotKeySet("{d up}", "du"){xxx up}, {xxx down} are for send. They don't work on HotKeySet. HotKeySet triggers when the key combo is released. Generator's code is the correct way, but the code has to be in a loop. TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode()
John Posted May 11, 2008 Posted May 11, 2008 The keyboard has a repeat delay and a repeat rate. This sript will work but your accuracy is limited by the repeat delay. Dim $diff, $i, $pole=0, $down=0 HotKeySet("a","ad") While 1 WEnd Func ad() $i=TimerInit() If $down=1 Then Return HotKeySet("a","up") $begin=TimerInit() While $pole<500; < Must be greater than keyboard repeat delay $pole=TimerDiff($i) WEnd $diff=TimerDiff($begin) MsgBox(0,$pole,$diff) HotKeySet("a","ad") $down=0 $pole=0 EndFunc Func up() $i=TimerInit() EndFunc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now