Jump to content

Help for simple test program


Recommended Posts

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
Link to comment
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.

Link to comment
Share on other sites

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]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...