Jump to content
Sign in to follow this  

holding key down not working in loop

Recommended Posts


im trying to make randomly hold 3 keys but its doesnt work any suggestions?

#cs ----------------------------------------------------------------------------

 AutoIt Version:
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

Global $Paused, $counter = 0
HotKeySet ("{HOME}", "Start")
HotKeySet ("{END}", "_Exit")

While 1

Func Start()
While 1
    call ("ClickRandomly")
    sleep (500)

Func ClickRandomly()
    Local $RandomNumber = Random(1,3,1)
    If $RandomNumber == 1 Then

send ("{a down}")
sleep (2000)
send ("{A UP}")
sleep (5000)

  If $RandomNumber == 2 Then

send ("{d down}")
sleep (2000)
send ("{d UP}")
sleep (5000)
       If $RandomNumber == 3 Then
send ("{w down}")
sleep (2000)
send ("{w UP}")
sleep (5000)


Func _Exit()


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  

  • Similar Content

    • BlazerV60
      By BlazerV60
      Hi all,
      I currently have this small script here:
      $T_INIT = TimerInit() Do Send("{DEL down}") Until TimerDiff($T_INIT) >= 2000 ;2000 miliseconds = 2 seconds, exactly how long it takes to delete one entire row in Microsoft Word Send("{DEL up}") What the above code does is hold down the delete key for 2 seconds.
      How would I make this script do the exact same thing if I had "DEL" as a variable? For example something like this: (Which by the way doesn't work)
      $ChosenKey = "DEL" $T_INIT = TimerInit() Do Send("{$ChosenKey& down}") Until TimerDiff($T_INIT) >= 2000 Send("{$ChosenKey& up}") All the parenthesis and "&" symbols and brackets make this difficult.
    • lee321987
      By lee321987
      I'm trying to hold a key down, but this is only pressing the key "a" one time and then releasing:
      Send("{a down}") MsgBox(0, '', '') EDIT:  really sorry, I forgot to search first.
      This question is answered here:  '?do=embed' frameborder='0' data-embedContent>>
      Please delete this thread if you want to.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.