whiteseal Posted March 21, 2009 Posted March 21, 2009 I am creating a simple test program. I want to set a hotkey and when I press the hotkey the program will hold down a button for several seconds. The program isn't working so far. Here is the code. HotKeySet( "q" , "key") Func key() Send( "{RIGHT DOWN}" ) Sleep(3000) Send("{RIGHT UP}") EndFunc
Authenticity Posted March 21, 2009 Posted March 21, 2009 It does send right down but the right key is not posted as being pushed by the user multiple times. You need something like this to get the effect: HotKeySet('q', 'key') Func key() Local $iInit = TimerInit() Do Send('{RIGHT}') Until TimerDiff($iInit) > 3000 EndFunc Also, you need a loop to hold you program from starting and terminating instantly.
herewasplato Posted March 21, 2009 Posted March 21, 2009 (edited) Welcome to the forum. try:HotKeySet("q", "key") While 1 Sleep(1000) WEnd Func key() Send("{RIGHT DOWN}") Sleep(3000) Send("{RIGHT UP}") EndFunc ;==>key Edit: if this is for a game - read the help file under SendKeyDownDelay: Alters the length of time a key is held down before being released during a keystroke. For applications that take a while to register keypresses (and many games) you may need to raise this value from the default. A value of 0 removes the delay completely. Time in milliseconds to pause (default=5). Edited March 21, 2009 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
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