Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Adding a delay between keystrokes


  • Please log in to reply
3 replies to this topic
Khalayne
  • Guests
  • Last active:
  • Joined: --
Hello,

I have a very simple script that goes like this.

$1:: ;
send {8}
send {f}
send {-}
send {0}
send {z}

return

This basically sends 8f-0z when i press 1. I use this is a game and i think the game has a problem with recognizing that many keys sent at the same time which messes up my macro. Is there a way i can add a miniscule, say 30 ms, delay between these keys?

Like this

$1:: ;
send {8}
30 ms delay
send {f}
30 ms delay
send {-}
30 ms delay
send {0}
30 ms delay
send {z}

return

I'm totally new to scripting and any help would be most appreciated.

Thanks :)

dmg
  • Members
  • 2395 posts
  • Last active: Nov 04 2015 06:46 AM
  • Joined: 19 Nov 2010
You should read about the Sleep command:
sleep, 30
:D
"My dear Mr Gyrth, I am never more serious than when I am joking."
~Albert Campion

-----------------------------------------------------------------------------------------------
Website | Demo scripts | Blog | External contact

LyrickCZE
  • Members
  • 51 posts
  • Last active: Feb 09 2012 09:18 PM
  • Joined: 29 Jan 2012
It is possible it will still not be enough. Using Send and sleep was sometimes inreliable for me in busy fullscreen application (game). What helped me was this:

SetKeyDelay , 30, 30 ; first is delay between keypresses, and second is press duration

; we are using ControlSend here because Send and SendInput is not affected by SetKeyDelay.
$1::
ControlSend, , 8, A 
ControlSend, , f, A 
ControlSend, , -, A
ControlSend, , 0, A
ControlSend, , z, A

Return
References: SetKeyDelay, ControlSend
Whenever someone says "pls" because it is shorter than "please", I say "no" because it is shorter than "yes"

Khalayne
  • Guests
  • Last active:
  • Joined: --
Awesome, thanks for a quick reply!

I'll give this a shot :)