How to make text appear every 20 minutes Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
MANIAx
Posts: 11
Joined: 27 Aug 2018, 06:05

How to make text appear every 20 minutes

Post by MANIAx » 27 Aug 2018, 13:15

Hi, I was wondering how to make a script that every 20 minutes presses t, types "/play bedwars_eight_one"(no quotes), and then presses enter

Thanks in advance :D

PS: I know this is probably very simple but I am a noob at this ;)

MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: How to make text appear every 20 minutes

Post by MannyKSoSo » 27 Aug 2018, 13:45

This can be done using the SetTimer method https://autohotkey.com/docs/commands/SetTimer.htm
So since we have a timer that we want to go off every 20 minutes we will start with converting minutes to milliseconds.
20 * 60 * 1000
This will be the time interval that we set the timer to go off since SetTimer wants the input in milliseconds.
Next is the variable you want to send, which can be done like this

Code: Select all

string := "/play bedwars_eight_one"
Even though I have surrounded it with quotes note that it will not send the quotes with it.
Now to bring everything together (you can do this with a label but I used a hotkey instead)

Code: Select all

SetTimer, Controlt, (20 * 60 * 1000)
string := "/play bedwars_eight_one"
Return

^t::
SendInput, t
Send, %string%
Send {Enter}
Return
Fyi I did not test this.
Last edited by MannyKSoSo on 27 Aug 2018, 13:56, edited 1 time in total.

MANIAx
Posts: 11
Joined: 27 Aug 2018, 06:05

Re: How to make text appear every 20 minutes

Post by MANIAx » 27 Aug 2018, 13:54

Thank you very much I have one question do I put string := "/play bedwars_eight_one" at the top of the second script you posted or run it as a separate ahk script with no other code?

Thanks again :D

MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: How to make text appear every 20 minutes

Post by MannyKSoSo » 27 Aug 2018, 13:56

yup, you can put it anywhere before the hotkey runs

MANIAx
Posts: 11
Joined: 27 Aug 2018, 06:05

Re: How to make text appear every 20 minutes

Post by MANIAx » 27 Aug 2018, 14:27

MannyKSoSo wrote:This can be done using the SetTimer method https://autohotkey.com/docs/commands/SetTimer.htm
So since we have a timer that we want to go off every 20 minutes we will start with converting minutes to milliseconds.
20 * 60 * 1000
This will be the time interval that we set the timer to go off since SetTimer wants the input in milliseconds.
Next is the variable you want to send, which can be done like this

Code: Select all

string := "/play bedwars_eight_one"
Even though I have surrounded it with quotes note that it will not send the quotes with it.
Now to bring everything together (you can do this with a label but I used a hotkey instead)

Code: Select all

SetTimer, Controlt, (20 * 60 * 1000)
string := "/play bedwars_eight_one"
Return

^t::
SendInput, t
Send, %string%
Send {Enter}
Return
Fyi I did not test this.
I tried this and there was an error on the second line that target label does not exist here is a link to the error message: https://youtu.be/0j90zA9r_Hk :headwall: :?

Thanks Again :D

MANIAx
Posts: 11
Joined: 27 Aug 2018, 06:05

Re: How to make text appear every 20 minutes

Post by MANIAx » 27 Aug 2018, 14:34

I realise now that I wrote it wrong and %string% should only be defined once but even after I fixed that it still did not work (same error) except now on line 1

MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: How to make text appear every 20 minutes

Post by MannyKSoSo » 27 Aug 2018, 14:41

Set ^t to Controlt and it should work

MANIAx
Posts: 11
Joined: 27 Aug 2018, 06:05

Re: How to make text appear every 20 minutes

Post by MANIAx » 27 Aug 2018, 14:46

So just to be clear do you define ^t like this Controlt := ^t or like this ^t := Controlt ?

Thanks

MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: How to make text appear every 20 minutes

Post by MannyKSoSo » 27 Aug 2018, 14:47

Code: Select all

SetTimer, Controlt, (20 * 60 * 1000)
string := "/play bedwars_eight_one"
Return

Controlt:
SendInput, t
Send, %string%
Send {Enter}
Return

MANIAx
Posts: 11
Joined: 27 Aug 2018, 06:05

Re: How to make text appear every 20 minutes

Post by MANIAx » 27 Aug 2018, 14:52

MannyKSoSo wrote:

Code: Select all

SetTimer, Controlt, (20 * 60 * 1000)
string := "/play bedwars_eight_one"
Return

Controlt:
SendInput, t
Send, %string%
Send {Enter}
Return
Sorry Again but there is still an error: https://imgur.com/a/BkfvjeU

MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: How to make text appear every 20 minutes  Topic is solved

Post by MannyKSoSo » 27 Aug 2018, 14:57

Code: Select all

SetTimer, Controlt, 1200000
string := "/play bedwars_eight_one"
Return

^t::
Controlt:
SendInput, t
Send, %string%
Send {Enter}
Return

MANIAx
Posts: 11
Joined: 27 Aug 2018, 06:05

Re: How to make text appear every 20 minutes

Post by MANIAx » 27 Aug 2018, 15:00

Thank you very very much I tested this with a ten second delay and it works :D

User avatar
AfterLemon
Posts: 85
Joined: 30 Sep 2013, 14:27
Location: Ohio, USA

Re: How to make text appear every 20 minutes

Post by AfterLemon » 26 Nov 2022, 12:24

Quick clarification as to the issue seen in the last few comments:

Code: Select all

SetTimer, Controlt, (20 * 60 * 1000)
will not work because SetTimer is a command and requires string inputs.

You can force expression syntax by using a parenthesis like

Code: Select all

SetTimer, Controlt, % (20 * 60 * 1000)
This evaluates 20*60*1000 to 1200000.
HOME: Windows 11 Pro | AMD Ryzen 7 5800X 8-Core @ 4.50GHZ | 64GB RAM
MOBILE: Samsung Galaxy Note 10+

Post Reply

Return to “Ask for Help (v1)”