Delay in between keystrokes

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
camazg
Posts: 2
Joined: 16 Oct 2018, 15:58

Delay in between keystrokes

16 Oct 2018, 16:03

Hi,

I am trying to create a script which presses the down arrow key 23 times, then presses enter. This is all inside a loop which repeats 100 times.

I am unable to create the necessary delay of 100ms in between key strokes of the down arrow. Is anyone able to identify what is wrong with the code I have written?

SendMode Play
SetMouseDelay,500
SetKeyDelay, 100,, Play

+p::
Loop,100
{
Send {Down 23}
Send {Enter}
} Esc::
ExitApp
return
User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Delay in between keystrokes

16 Oct 2018, 16:13

Code: Select all

#SingleInstance, Force

+p::
	Loop, 100 {
		Loop, 23 {
			Send, {Down}
			Sleep, 100
		}
		
		Send, {Enter}
	}
return

Esc::
	ExitApp
return
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Delay in between keystrokes

16 Oct 2018, 16:41

Probably SetKeyDelay only works between Sends.

Code: Select all

Send {Down 23}
Send {Enter}
I guess the key delay is only between down and enter.
It is not within the Down 23.

Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
eelrod
Posts: 65
Joined: 10 Apr 2018, 11:17

Re: Delay in between keystrokes

17 Oct 2018, 08:21

Personally, I often have issues with SendPlay (likely stemming from my own ignorance). Anyway, I would suggest using SendEvent. Try this:

Code: Select all

+p::
SetKeyDelay , 100
Loop , 100
    SendEvent , {down 23}{enter}
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, mcd, rubeusmalfoy, ShatterCoder and 79 guests