Less than serious, I suppose... but I've recently got slightly addicted to a silly game called Cookie Clicker. And I made this, to automate clicking on the cookie to bake more cookies. (Look, I SAID it was silly.)
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 Action: Comment "This macro was targeted for: Cookie Clicker"
0002 Action: Comment "You can edit the 'Window: Assign' step to change the target."
0003 Window: Assign "Cookie Clicker.exe"
0004 ;Window: Resize to "1696,1089"
0005 Macro: For assigned window only "1"
0006 Window: Activate for use ""
0007 Macro: Typing speed "def"
0008 Action: Comment "You can right-click the next step to change the macro speed."
0009 Alert: Ask for a line of text "How many clicks?"
0010 Action: Repeat this block "alert$"
0011 Macro: Type keys or use mouse "{@370,600}{leftclick}{z25}"
0012 Action: End of block ""
(End)
Generally, it works pretty well. But if I set it off to do -- say -- 500,000 clicks while I go off and do something else, if I interrupt it (by pressing Esc) it generally stops and restarts, then after a more energetic Esc (by leaning on the key for a couple of seconds) it stops OK but, after a few seconds, so does Toolbox.
For clicks up to a few thousand, it's fine, so I'm wondering if there's a counter somewhere that's objecting to the size of the loop?
Hi Oblivion,
I tested the following action at https://cpstest.org/10-seconds.php to see if all clicks were being registered, and they were. Just make sure your mouse is over the click area before pressing the hotkey to start it. It should report that all 500 were successfully clicked. The reason I mention this is because some apps or websites might not be able to respond to each and every click if they're too fast.
As for your game issue with the Esc key, it sounds like your single keypress of Esc is coincidentally happening during your "{z25}" delay, so the action misses the press and doesn't abort the action at that moment. That's why holding it down works, because the 25 ms timeout ends while you're still holding down the Esc key.
If Toolbox's window is also closing, that would be because pressing the Esc key on it will hide it (until you use its main hotkey to show it again). So make sure it's closed when running the action to avoid that.
Lastly, the limit of repeated loops is 2147483647 (a "long" in computer terms), or you can specify "forever" to repeat indefinitely.
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 Action: Repeat this block "500"
0002 Macro: Type keys or use mouse "{leftclick}"
0003 Action: End of block ""
(End)
(https://www.alomware.com/images/forum/mouse-clicks.png)
Thanks for looking, Paul.
The script is fine up to about 15000 clicks -- haven't tested it incrementally beyond that. The problems only occurred with loops of half a million and beyond but I think what I might do is put in a condition to click indefinitely if the number input is >99,999 -- see what happens then. If the issue is "too many loops" it'll happen again, and if it's "counting down from half a million" then it won't. :)
Mouse positioning isn't an issue as I'm handling that within the script anyway.
Oh. Well, that was a quick experiment.
The updated code is:
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 Action: Comment "This macro was targeted for: Cookie Clicker"
0002 Action: Comment "You can edit the 'Window: Assign' step to change the target."
0003 Window: Assign "Cookie Clicker.exe"
0004 Macro: For assigned window only "1"
0005 Window: Activate for use ""
0006 Macro: Typing speed "def"
0007 Alert: Ask for a line of text "How many clicks?"
0008 String: Assign "alert$"
0009 Action: Do next step if "string$>99999"
0010 String: Assign "forever"
0011 Action: Repeat this block "string$"
0012 Action: Comment "Next line is for external monitor, line after for internal"
0013 Macro: Type keys or use mouse "{@370,600}{leftclick}{z25}"
0014 ;Macro: Type keys or use mouse "{@300,450}{leftclick}{z25}"
0015 Action: End of block ""
(End)
So it works, as far as it goes. Asking for 1000 clicks in line 7 delivers 1000 clicks then ends. Asking for 5000 clicks in line 7 and then interrupting (with Esc) after a thousand or two aborts processing as expected.
Asking for 5000000 clicks should set the block repeat instruction in line 11 to "forever" -- and apparently does. However, while it clicks away cheerfully at the assigned location indefinitely, an interruption (which is now a requirement!) needs to be made twice and then Toolbox terminates. Toolbox is running as admin (it can't see the target program if not, for some reason) and minimised.
The block that's being executed doesn't change, just the loop parameters do. And it's not about the number of times you go round the loop, I don't think, because it neither crashes nor fails to complete 5000, but DOES crash if it's been round the loop with the "forever" parameter fewer than 5000 times and is then terminated with Esc.
Have you got another free app that you (and I) can test it with? I don't want to buy Cookie Cutter on Steam just to look deeper into it.
When you say Toolbox terminates, do you mean it literally crashes or quits so that it's no longer running?
I think you can test it with anything. Open notepad fullscreen and let it rip.
As far as I can tell, it's utterly reliable as long as you're not triggering the forever parameter on the block that starts on line 11. Only one Esc required to terminate it. If it's running indefinitely (or, previously, with a very large number for the loop) then a single Esc causes a hiccup and a continue, then Esc needs to be leaned on, then Toolbox (quietly) crashes. No errors, nothing like that, it just goes away.
For what it's worth, I've reworked it slightly so I don't have to remember which coordinates I want the mouse to click at. The action now looks like this:
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 Action: Comment "This macro was targeted for: Cookie Clicker"
0002 Action: Comment "You can edit the 'Window: Assign' step to change the target."
0003 Window: Assign "Cookie Clicker.exe"
0004 Macro: For assigned window only "1"
0005 Window: Activate for use ""
0006 Macro: Typing speed "def"
0007 Alert: Ask for a choice "Where is Cookie Clicker?~External monitor~Laptop screen~"
0008 Action: Do this block if "alert$=External monitor"
0009 Alert: Ask for a line of text "How many clicks?"
0010 String: Assign "alert$"
0011 Action: Do next step if "string$>99999"
0012 String: Assign "forever"
0013 Action: Repeat this block "string$"
0014 Macro: Type keys or use mouse "{@370,600}{leftclick}{z25}"
0015 Action: End of block ""
0016 Action: End of block ""
0017 Action: Do this block if "alert$=Laptop screen"
0018 Alert: Ask for a line of text "How many clicks?"
0019 String: Assign "alert$"
0020 Action: Do next step if "string$>99999"
0021 String: Assign "forever"
0022 Action: Repeat this block "string$"
0023 Macro: Type keys or use mouse "{@300,450}{leftclick}{z25}"
0024 Action: End of block ""
(End)
However, I think you could test just by opening notepad fullscreen and running a script that just consisted of lines 21-24 then aborting it with Esc after 20 seconds or so.
I've just tried it.
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 String: Assign "forever"
0002 Action: Repeat this block "string$"
0003 Macro: Type keys or use mouse "{@300,450}{leftclick}{z25}"
0004 Action: End of block ""
(End)
You won't see much happening, apart from the flickering of the Toolbox icon in the notification area, but you should see exactly what I mean when you try to stop the loop.
Okay, I can see what you mean now, from your last snippet. Here's what's happening: The Esc key is correctly aborting the macro in step 3, as expected. But then you're restarting the same aborted macro again immediately... and forever. ;) So you need to manually check for the Esc key being held down in the block (step 4 below), and then abort the repeating block as well. Like this:
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 String: Assign "forever"
0002 Action: Repeat this block "string$"
0003 Macro: Type keys or use mouse "{leftclick}{z25}"
0004 Action: Do next step if "{esc}=0"
0005 Action: End of block ""
(End)
Having said this, the action shouldn't crash Toolbox when done your original way, so I need to look into that. :)
OK, that seems to fix it. Still don't really understand why the "forever" loop behaves differently to the finite version but a fix is a fix :)
I've rewritten the code to simplify things a bit. Well, quite a lot. It's now just a forever loop.
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 Action: Comment "This macro was targeted for: Cookie Clicker"
0002 Action: Comment "You can edit the 'Window: Assign' step to change the target."
0003 Window: Assign "Cookie Clicker.exe"
0004 Macro: For assigned window only "1"
0005 Window: Activate for use ""
0006 Macro: Typing speed "def"
0007 Alert: Ask for a choice "Where is Cookie Clicker?~External monitor~Laptop screen~"
0008 Action: Do next step if "alert$=blank$"
0009 Action: Finish ""
0010 Action: Repeat this block "forever"
0011 Action: Do next step if "alert$=External monitor"
0012 Macro: Type keys or use mouse "{@370,600}{leftclick}{z25}"
0013 Action: Do next step if "alert$=Laptop screen"
0014 Macro: Type keys or use mouse "{@300,450}{leftclick}{z25}"
0015 Action: Do next step if "{esc}=1"
0016 Action: Finish ""
0017 Action: End of block ""
0018 Action: Finish ""
(End)
I thought about posting this in the Tips area but I remain determined that 15 and 16 shouldn't be necessary (and don't need to be present if the loop's set to repeat for, say, 10000 steps), and that the coding's very specific to a two-monitor setup where the monitors have different characteristics, so it's barely even a template...
And I only mention it at all because my first go at this routine set string$ to the appropriate coordinates then tried to click {@string$} and it didn't work. So maybe that's a request? ;)
Quote from: oblivion on April 02, 2026, 11:27:46 PMI remain determined that 15 and 16 shouldn't be necessary
I think you're misunderstanding how Esc works with "Macro: Type keys or use mouse". Pressing it does indeed abort the macro, but you're then restarting the macro
again (because it's in a loop), so the old escaped macro has correctly stopped but a new one has started instead. It's like whack-a-mole. That's why an extra check for Esc is needed (step 15) to abort the
loop itself, instead of just aborting the
macro. Steps 15 and 16 are need to make it like pulling out the plug on a whack-a-mole machine so no more moles can pop up after you whack one (Esc on the macro).
Quote from: oblivion on April 02, 2026, 11:27:46 PMtried to click {@string$} and it didn't work
This works here as expected:
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 String: Assign "123,456"
0002 Macro: Type keys or use mouse "{@string$}{leftclick}{z25}"
(End)
Hi Paul,
Try this. Notepad fullscreen, Toolbox minimised. The test from previously, with a single modification, then try to abort it with Esc.
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 String: Assign "10000"
0002 Action: Repeat this block "string$"
0003 Macro: Type keys or use mouse "{@300,450}{leftclick}{z25}"
0004 Action: End of block ""
(End)
Esc stops it and it (a) doesn't restart, and (b) doesn't crash Toolbox.
Change the parameter in line 1 by adding a pair of zeroes to the end, try again. This time, the loop stutters and continues until you hold Esc down and, once it's stopped, the crash happens.
Now do you see why I think it's a bug?
Quote from: oblivion on April 03, 2026, 01:43:05 PMNow do you see why I think it's a bug?
Found the issue (and it wasn't technically a bug). It's to do with resetting the auto-complete function of Toolbox. It gets disabled when a macro is run so that the macro doesn't auto-complete anything, and then resets when the macro is done; but this reset wasn't expecting a macro to be run thousands of times repeatedly. You never know what a user will come up with. :) I'll have to make it not reset if an action is currently inside a loop, and only reset once out of it.
I was starting to think it was something external to Toolbox meaning me seeing something different to you! Thanks for confirming the issue :)
And yes, sometimes I probably am that annoying edge case. If that's the phrase. :D
Hi oblivion. I just sent you an email with a new test version that should stop the Esc key crashing the app. Well, it stops it here. :) Please reply here with how it goes for you. Thanks!
Thanks, Paul, I'll give it a go.
It's still bugging me slightly that Esc fails in a forever loop even if it's pressed more or less straight away, but doesn't fail in a finite (say 5000) loop whenever it's pressed. But I'll try the update and see what happens. :)
(Might not be today, though, we're going to see some flavour of Queen tribute act in a bit and probably not worrying about loops very much during it!)
It fails in a forever loop if you don't use the Esc key test after the macro (using "Action: Do next step if "{esc}=1" after the macro).
Pressing Esc only appears to work in a finite test of 5000 (or even 50000) repetitions because those loops end pretty much immediately... so it's not Esc stopping them, but the loop ending naturally. A loop of 50000 is over extremely quickly, and I think you're assuming that pressing Esc is what's ending it (it's not). You can see for yourself with this and check the Log tab when the action ends; it'll show 49999 which means Esc isn't what stopped it. Esc stopping it should show a much lesser number.
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 Action: Repeat this block "50000"
0002 Macro: Type keys or use mouse "{@1500,35}{leftclick}{z25}"
0003 Action: End of block ""
0004 Log: Add text "repeat$"
(End)
I'll try the logging thing.
But unless the clicks are getting buffered in some way, a loop of 5000 takes a noticeable amount of time to complete. 5000 clicks x 25 milliseconds is 125 seconds, or just over 2 minutes. I can terminate a 5000 loop after 5 seconds with a single Esc and it'll stop. If I try to terminate a forever loop without a test for Esc by pressing the Esc key, even after 5 seconds, it'll continue indefinitely -- which is what's happening with the update, even by holding Esc down. (The only way out of a forever loop without a test is to hold Esc down then right-click on Toolbox and exit without letting go of the Esc key.)
But I really have to go now. I understand what you're saying but I don't think it quite aligns with what's actually happening. I'll try to get back to this tomorrow.
Okay, I worked it out. It was a wrongly-used failsafe code for the Esc key when a macro starts, which shouldn't really be there (sometimes I go overboard with checking the safety of things). Now that I've removed it, you can no longer incorrectly terminate your 5000 loop anymore with this code (which is logically correct):
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 Action: Repeat this block "5000"
0002 Macro: Type keys or use mouse "{@1500,35}{leftclick}{z25}"
0003 Action: End of block ""
(End)
To currently correctly terminate this action early with the Esc key, it has to be done like this:
(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 Action: Allow failure messages "0"
0002 Action: Repeat this block "5000"
0003 Macro: Type keys or use mouse "{@1500,35}{leftclick}{z25}"
0004 Action: Continue if "{esc}=0"
0005 Action: End of block ""
(End)
This is the correct way. This change will be in the next Toolbox release.
OK, thanks Paul, sorry it's taken a while to get back to this. I can confirm that I've ensured my code follows the requirements for forever loops and it's now completely consistent and completely solid.
Thanks for confirming. :)