is there more professional way to write this Simple ... Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Barney15
Posts: 121
Joined: 12 Jan 2020, 14:18

is there more professional way to write this Simple ...

07 Apr 2020, 12:11

this code is working good, but is there a better way to write this on one line for example or any other method to send two keys with sleep time in between in one line.

Code: Select all

Send, ^{r}
Sleep,1000
Send, {Enter}
teadrinker
Posts: 1633
Joined: 29 Mar 2015, 09:41
Contact:

Re: is there more professional way to write this Simple ...  Topic is solved

07 Apr 2020, 12:17

For me this works:

Code: Select all

Send ^{r}{Sleep 100}{Enter} ; 100 = 1s
Barney15
Posts: 121
Joined: 12 Jan 2020, 14:18

Re: is there more professional way to write this Simple ...

07 Apr 2020, 12:21

well it work with variable speed ?
eg :

Code: Select all

speed = 100
Send ^{r}{Sleep %speed%}{Enter}
gregster
Posts: 4470
Joined: 30 Sep 2013, 06:48

Re: is there more professional way to write this Simple ...

07 Apr 2020, 13:56

teadrinker wrote:
07 Apr 2020, 12:17
For me this works:

Code: Select all

Send ^{r}{Sleep 100}{Enter} ; 100 = 1s
Wouldn't this send the Sleep keyboard key a hundred times (which obviously would take some time - but how much might depend on key delay settings and send mode, I guess), which wouldn't be equivalent to Sleep (sure, obvious, if 100 = 1s). Well, if it works for the use case... but I would hesitate to call it "a better way", "more professional" or "simpler", which you asked for, Barney15. It's more "any other method". Edit: Not sure, if there could be side-effects in some programs.

I don't know, what does the Sleep key usually do? I don't think I have one.
teadrinker
Posts: 1633
Joined: 29 Mar 2015, 09:41
Contact:

Re: is there more professional way to write this Simple ...

07 Apr 2020, 14:16

I have no such key too, and I don't know how it works for sure. I've just remembered that I saw that approach somewere, I checked it — it turned working for me.
gregster
Posts: 4470
Joined: 30 Sep 2013, 06:48

Re: is there more professional way to write this Simple ...

07 Apr 2020, 14:19

Yes, I have also seen it before. That's why I remember that it works somehow... but I wanted to mention it, to avoid confusion.
(AHK knows a Sleep key, according to the docs.)
TAC109
Posts: 532
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: is there more professional way to write this Simple ...

07 Apr 2020, 16:35

teadrinker wrote:
07 Apr 2020, 12:17
For me this works:

Code: Select all

Send ^{r}{Sleep 100}{Enter} ; 100 = 1s
The {Sleep 100} will simply sent the sleep key 100 times. There is no way in AutoHotkey_L to include a sleep command directly into the send string.

You may be thinking of AutoHotkey_H which allows this facility:

Code: Select all

Send ^{r}{1000}{Enter} ; sleep 1000ms before Enter
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts
Barney15
Posts: 121
Joined: 12 Jan 2020, 14:18

Re: is there more professional way to write this Simple ...

07 Apr 2020, 17:57

TAC109 and gregster, thank you for information,
because at first i didn't know why the value of sleep changed suddenly to became in ms, it's turned up that it's became a key that sent certain number of times, + in my script i use setkeydelay and that may effect it too, since sleep behaves as a key.
still it's a good way too
TAC109
Posts: 532
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: is there more professional way to write this Simple ...

07 Apr 2020, 18:39

Of course, if the Sleep key on the computer is configured to actually sleep or hibernate, there will be a much longer pause! :D
My programs:-
ReClip - a Text Reformatting and Clip Management utility
XRef - Produces Cross Reference lists for scripts
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: is there more professional way to write this Simple ...

07 Apr 2020, 19:01

Depending on your use case, this would also work.

Code: Select all

setKeyDelay,1000 ; specify this in the auto-execute, or at the beginning of a logical thread (hotkey, timer, etc.)

send ^{r}{Enter}
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], boiler, DonaldKenneth, Google [Bot] and 333 guests