Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Persistent
SetTimer, PressTheKey, 35712
Return
PressTheKey:
Click
sleep, 500
Click
Return
About this script and its future: I am planning to make numerous advances for this script, but this was the first iteration. So the entire function of this script is every 35 seconds, my mouse clicks, waits 500ms, then clicks again. It works for what I need it to do, which is click! Later I plan to make it much more complex. As an end result I would like it to move to a pre-determined location, click, wait, click, move to another location, etc. After I get that operational I would like to go a little deeper and start using some randomness, in which it clicks between a say ever 20-40 seconds. After that I want to go even further and instead of moving to position (xxx,yyy), I would like it to move to a random location inside of a small area, if that makes sense. I am a loooong way from this, but I am quite excited to learn this.
What I need help with: So the main problem I have at this point is I can't figure out how to make the script repeat 1,000 times then stop. It just seems to run on repeat forever. (I think this is because of the #Persistent at the top of the script?).
How I want it to function:
I would like to run the script manually (because making it start on its own seems impossible?).
Have the script perform its current code 1,000 times (click 1000 times, every 35 seconds, with a .500 sleep between the clicks.
After the 1,000th click, I would like it to stop, either via just stopping the clicks or closing the script either one.
I have tried Exit and ExitApp, but I don't think I am using them correctly, because it never stopped, and even if I did I don't know how to make it exit only after 1k clicks. I have tried google, reading a ton of other threads, and looking in the AHK.docs but this is kind of complicated for a first time seeing it. Thank you for any help. I hope to pick up more knowledge along the way!