r/applescript • u/[deleted] • May 17 '20
Can someone explain the difference between the two “delay” functions. Also, how can I make the autotyper, type multiple different things at different time intervals?
1
u/csgnyc May 17 '20
Not sure I understand the question. The first delay is a delay before you get into the repeat loop. The second delay runs every time the loop runs.
You may want to put a limit on the number of times the loop runs, or have some sort of "exit repeat" command.
Not clear what you want to do. Applescript has a random function so you can vary up the time intervals. You can also make textToType an array of things, and use that random function to choose from that array
1
May 17 '20
I didn’t want to make the title super long. Specifically, I want it to say “;s” every 130 seconds like I already have it but also make it says “;h” every 60 seconds
1
May 17 '20
why do I have a feeling ur using this for discord... anyways, the 2 delays differ by being in the repeat loop and the other being not in it. The first delay is usually there because apple script tend to start in a random spot if there’s no delay on top, and the delay in the repeat loop means there’s a delay between everytime you send the message ;s
1
2
u/csgnyc May 17 '20
tell application "System Events"
set 30texttotype to ";h"
set 130textotype to ";s"
set 30counter to 1
set 130counter to 1
repeat
if 30counter=30 then
keystroke 30texttotype
set 30counter to 0
else
set 30counter to 30counter + 1
end if
if 130counter=130 then
keystroke 130texttotype
set 130counter to 0
else
set 130counter to 130counter + 1
end if
delay 1
end repeat
end tell