12-26-2004, 09:41 AM
Function KeyRepeat
function vk ^duration [speed]
;vk - virtual-key code (see QM Help, virtual-key codes topic)
;duration - number seconds to hold key down
;speed - number of milliseconds between repeated keypresses
;EXAMPLE
;;hold down spacebar for 5 seconds
;KeyRepeat 32 5
;EXAMPLE2
;;the same, but continue macro immediately
;mac "KeyRepeat" "" 32 5
int t1 t2
duration*1000
if(speed<1) speed=50
t1=GetTickCount
spe
rep
,key+ (vk)
,wait speed/1000.0
,if(duration<0) continue
,t2=GetTickCount
,if(t2>t1+duration or t2<t1) break
key- (vk)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;