Counter after finishing a loop
Posted: 22 Mar 2024, 11:42
So what I'm creating is a macro which will auto grind my game progress (the game is like tower defense where you place unit to defend the base). It basically will run a set of mouse click that are positioned and timing set. When it cleared all the waves or lose, the play again button will appear (which I've used ImageSearch to detect and click the play again button). Everything works just fine and I could just leave it to run for a night.
But what I need help about is that everytime the game lost and won. I want to get a counter for that. Basically a 5 type of counter. 1. Game lost at 2 mins 2. Game lost at 5 mins 3. Game lost at 10 mins 4. Game won/finished at 15 mins.
Where do I put the counter? I read every other forms and can't understand how to use it. I really need example for this.
Also it's like I'm going to the macro over night, wakes up in the morning, press a key and see 5 counters of what I've mentioned.
Here is the code
But what I need help about is that everytime the game lost and won. I want to get a counter for that. Basically a 5 type of counter. 1. Game lost at 2 mins 2. Game lost at 5 mins 3. Game lost at 10 mins 4. Game won/finished at 15 mins.
Where do I put the counter? I read every other forms and can't understand how to use it. I really need example for this.
Also it's like I'm going to the macro over night, wakes up in the morning, press a key and see 5 counters of what I've mentioned.
Here is the code
Code: Select all
F5::Pause
F3::ExitApp
F4::
Start:
Loop
{
; ImgSearch loop until found start button to run a set of mouse clicks
}
; a set of mouse clicks from 0 second to 2 minutes
CoordMode, Pixel, Screen ; 2 minutes game lost checking
ImageSearch, FoundX, FoundY, 0, 0, 1920, 1080, *50 D:\Stuff\playagain1.png
if (ErrorLevel = 0)
{
MouseClick, L, 1284, 782
Goto Start
}
else
; continue a bunch of clicks
CoordMode, Pixel, Screen ; 5 minutes game lost checking
ImageSearch, FoundX, FoundY, 0, 0, 1920, 1080, *50 D:\Stuff\playagain1.png
if (ErrorLevel = 0)
{
MouseClick, L, 1284, 782 ; click "playagain" button
Goto Start ; go back to the start
}
else
; continue a bunch of clicks
CoordMode, Pixel, Screen ; 10 minutes game lost checking
ImageSearch, FoundX, FoundY, 0, 0, 1920, 1080, *50 D:\Stuff\playagain1.png
if (ErrorLevel = 0)
{
MouseClick, L, 1284, 782 ; click "playagain" button
Goto Start ; go back to the start
}
else
; continue a bunch of clicks
CoordMode, Pixel, Screen ; 10 minutes game lost checking
ImageSearch, FoundX, FoundY, 0, 0, 1920, 1080, *50 D:\Stuff\playagain1.png
if (ErrorLevel = 0)
{
MouseClick, L, 1284, 782 ; click "playagain" button
Goto Start ; go back to the start
}
else
; continue a bunch of clicks and finish
CoordMode, Pixel, Screen
Loop ; img search until playagain button is found
{
ImageSearch, FoundX, FoundY, 0, 0, 1920, 1080, *50 D:\Stuff\playagain1.png
}
Until, (ErrorLevel = 0)
MouseClick, L, 1284, 782 ; click "playagain" button
} ;finish the whole thing and go back to the loop beginning