How do you combine "Send" and "sleep" in one line?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
howardRaul1
Posts: 4
Joined: 10 Dec 2023, 01:06

How do you combine "Send" and "sleep" in one line?

13 Dec 2023, 01:48

How do you combine "Send" and "sleep" in one line? The following example doesn't work:

Code: Select all

a::{Send "b"},{sleep 1}
I noticed that SoundBeep() and MsgBox() can be combined in one line (please see the URL below). I am not sure why "Send" and "sleep" cannot be combined the same way.

viewtopic.php?t=116521

Thanks!
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: How do you combine "Send" and "sleep" in one line?

13 Dec 2023, 02:30

howardRaul1 wrote: I noticed that SoundBeep() and MsgBox() can be combined in one line (please see the URL below). I am not sure why "Send" and "sleep" cannot be combined the same way.
They can be combined in exactly the same way, which is not what you did. It doesn’t follow anything shown or explained in the other thread. It is not correct syntax for either one, let alone combined.

Code: Select all

#Requires AutoHotkey v2.0
a::Send("b"), Sleep(1)
User avatar
xMaxrayx
Posts: 237
Joined: 06 Dec 2022, 02:56
Contact:

Re: How do you combine "Send" and "sleep" in one line?

13 Dec 2023, 10:25

if you are interested you can use ahkv2-H they can do sleep {N} like this

Code: Select all

send("Hello{250}what is that?!!{100}look it's behind you!{50}it's a monster!")
Last edited by xMaxrayx on 14 Dec 2023, 01:41, edited 1 time in total.
-----------------------ヾ(•ω•`)o------------------------------
https://github.com/xmaxrayx/
howardRaul1
Posts: 4
Joined: 10 Dec 2023, 01:06

Re: How do you combine "Send" and "sleep" in one line?

13 Dec 2023, 16:27

Hi @xMaxrayx,

I tried your code in v2, but the code doesn't produce the intended delays of 250ms/100ms/50ms.

The v2 documentation on Send() also didn't mention this feature. Is this a beta feature?

Thanks!
User avatar
FanaticGuru
Posts: 1908
Joined: 30 Sep 2013, 22:25

Re: How do you combine "Send" and "sleep" in one line?

13 Dec 2023, 20:10

xMaxrayx wrote:
13 Dec 2023, 10:25
if you are interested you can use ahkv2-H they can do sleep {N} like this

Code: Select all

send("hello{250}what!!{100}look behind you{50}it's monster")

Here is a version for vanilla AHK v2.

Code: Select all

StutterSend("hello{250}what!!{100}look behind you{50}it's monster")

StutterSend(Text)
{
	For Line in StrSplit(Text, '}')
	{
		Elements := StrSplit(Line, '{')
		Send Elements[1]
		try Sleep Elements[2]
	}
}
This code has been rigorously tested twice for nearly 5 seconds and worked perfectly in that time.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
User avatar
xMaxrayx
Posts: 237
Joined: 06 Dec 2022, 02:56
Contact:

Re: How do you combine "Send" and "sleep" in one line?

14 Dec 2023, 01:33

howardRaul1 wrote:
13 Dec 2023, 16:27
Hi @xMaxrayx,

I tried your code in v2, but the code doesn't produce the intended delays of 250ms/100ms/50ms.

The v2 documentation on Send() also didn't mention this feature. Is this a beta feature?

Thanks!
Hi ,sorry it's not in the vanilla AHKv2 it's for AHKv2-H.

AHKv2-H https://hotkeyit.github.io/v2/
Sleep functionality for Send command, for example Send 123{100}456 would send 123 then sleep for 100 milliseconds and send 456.
https://hotkeyit.github.io/v2/docs/AutoHotkey.htm



@FanaticGuru oh wow great nice function <3, I think we can add another if statement to check if the {variable} is a number or not ,so it won't get mixed with {Enter} or {LCtrl Down}
-----------------------ヾ(•ω•`)o------------------------------
https://github.com/xmaxrayx/

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: kunkel321, shipaddicted, Spikea and 66 guests