Sign in to follow this  
Followers 0
whiteseal

Help for simple test program

3 posts in this topic

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

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0