Script request.

Ask gaming related questions (AHK v1.1 and older)
Liamshimmo
Posts: 1
Joined: 23 Feb 2018, 05:06

Script request.

23 Feb 2018, 05:11

Hi,

Looking for a script which does the following..

F5 Key then a second later press the enter key.
This must be on a 2 minute interval.

Thanks!
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Script request.

23 Feb 2018, 15:21

Code: Select all

#NoEnv
#Persistent
gosub, spam
SetTimer, spam, 120000
return

spam:
    Send, {F5}
    Sleep, 1000
    Send, {Enter}
return
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Script request.

25 Feb 2018, 02:35

Xtra wrote:

Code: Select all

#NoEnv
#Persistent
gosub, spam
SetTimer, spam, 120000
return

spam:
    Send, {F5}
    Sleep, 1000
    Send, {Enter}
return
Question. Won't the gosub redirect to the label spam every persistent? Or does the gosub disable after it hits a return?
I am your average ahk newbie. Just.. a tat more cute. ;)
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Script request.

25 Feb 2018, 21:04

The gosub only runs one time. The timer is left running when the return is reached.
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Script request.

26 Feb 2018, 01:16

Xtra wrote:The gosub only runs one time. The timer is left running when the return is reached.
What if gosub is under a hotkey? or a label? Ah I tried and it does work under a hotkey, more than once. But then why does it trigger only once under persistent which is supposed to run the script infinitely many times right? Oh is it because the settimer thread is still running? But then what is the point of persistent in the script at all??
I am your average ahk newbie. Just.. a tat more cute. ;)
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Script request.

26 Feb 2018, 12:12

#Persistant makes the script not exit.
From the docs:
If this directive is present anywhere in the script, that script will stay running after the auto-execute section (top part of the script) completes. This is useful in cases where a script contains timers and/or custom menu items but not hotkeys, hotstrings, or any use of OnMessage() or Gui.
Gosub only runs once because it was put in the auto-execute section.
The Top of the Script (the Auto-execute Section)

After the script has been loaded, it begins executing at the top line, continuing until a Return, Exit, hotkey/hotstring label, or the physical end of the script is encountered (whichever comes first). This top portion of the script is referred to as the auto-execute section.

A script that is not persistent and that lacks hotkeys, hotstrings, OnMessage, and GUI will terminate after the auto-execute section has completed. Otherwise, it will stay running in an idle state, responding to events such as hotkeys, hotstrings, GUI events, custom menu items, and timers.
When in doubt check the docs.

HTH

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 46 guests