Hints, tips and tricks for newbies
Moderators: Dorian (MJT support), JRL
-
grashopa
- Newbie
- Posts: 2
- Joined: Mon Oct 28, 2013 7:47 am
Post
by grashopa » Mon Oct 28, 2013 7:53 am
I'm playing this stupid game called cookie clicker that my nephew got me to play. so i created this macro for infinite loop clicking the mouse. no mouse placement because i just hit f9 when im hovering over the cookie.
repeater works fine and the stop macro works to BUT when you stop macro it give the error which is listed at the bottom of code. can someone please help me so i don't have to keep click abort when i want to end the loop.
Code: Select all
//cookie clicker - loop to click on the cookie
//www.orteil.dashnet.org/cookieclicker/
//repeater infinit loop
label>start
//end macro - Press the letter "a" to stop macro
OnEvent>KEY_DOWN,a,0,Shutdown
SRT>Shutdown
Goto>end_macro
END>Shutdown
LDblClick
wait>0.03
//repeater infinit loop
goto>start
//end macro - once you press "a" then press "ALT a" to abort error
Label>end_macro
//can someone fix this so i don't have to
//abort the error everytime i want to stop
//the macro?
//branching out of subroutine is not recomended and may result in memory loss
//subroutines should be allowed to run to thier end
// this is the error i get and have to abort out of.
-
Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
-
Contact:
Post
by Grovkillen » Mon Oct 28, 2013 8:32 am
One big thing is that you have the label "start" above the "On event" and Subroutines... this mean that you load those every 0.03 seconds.
Code: Select all
OnEvent>KEY_DOWN,a,0,Shutdown
//repeater infinit loop
label>start
LDblClick
wait>0.03
goto>start
//Subroutines...
SRT>Shutdown
Goto>end_macro
END>Shutdown
-
grashopa
- Newbie
- Posts: 2
- Joined: Mon Oct 28, 2013 7:47 am
Post
by grashopa » Mon Oct 28, 2013 5:07 pm
this works as well and alot simpler than my code thx. but it still give an error. a new error but an error.. its just for this clicking game.. ill deal with it.
-
Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
-
Contact:
Post
by Grovkillen » Mon Oct 28, 2013 6:57 pm
Next thing to change is the "goto>end_macro" which should be "exit>0" because thats how you end a macro.
-
fightcancer
- Macro Veteran
- Posts: 250
- Joined: Fri Apr 15, 2005 8:32 am
Post
by fightcancer » Wed Jun 18, 2014 6:41 am
I'm getting this error ("Branching out of subroutine is not recommended and may result in memory loss...") also on Line 163 of my macro.
Here is line 163.
Goto>StartMainLoop
The error cannot mean what it says because line 163 is NOT in a SRT.
-
PaulSR
- Pro Scripter
- Posts: 65
- Joined: Mon Aug 05, 2013 2:58 pm
- Location: Edinburgh/Peterborough
Post
by PaulSR » Wed Jun 18, 2014 8:10 am
fightcancer wrote:I'm getting this error ("Branching out of subroutine is not recommended and may result in memory loss...") also on Line 163 of my macro.
Here is line 163.
Goto>StartMainLoop
The error cannot mean what it says because line 163 is NOT in a SRT.
I've had this one before - are you sure that line 163 isn't running as part of a call from an SRT? Stepping through my code from the start it turned out I'd done exactly what it said. Worth doing a step-through to ensure any/all SRT's you have called during the code execution have ran to conclusion before this point.
-
fightcancer
- Macro Veteran
- Posts: 250
- Joined: Fri Apr 15, 2005 8:32 am
Post
by fightcancer » Wed Jun 18, 2014 3:28 pm
Yes I'm sure, and yes you're right. There was a Goto statement in a SRT that exited that SRT before it completed. The macro then ran 5 separate SRTs to completion before generating that error message--and with that incorrect line number. It's as if error handling has the right logic but the wrong line number identification. Hopefully it can be fixed.
Regardless, thanks for steering me in the right direction!
-
CyberCitizen
- Automation Wizard
- Posts: 721
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
Post
by CyberCitizen » Wed Jun 18, 2014 11:09 pm
Here was a script I wrote years ago for something similar (used to just send mouse clicks based on the position of the mouse.
I'm sure I could clean up the code and make it more useful and cleaner, however has been working fine for years compiled so I haven't updated it.
Let>APP_TITLE=Mouse Press
Let>INPUT_BROWSE=0
Input>wait,Please Enter The Amount Of Time You Want To Wait%CRLF%Before The Next Key Press (In Seconds) Example: 3 or 3.5
If>%wait%=,Exit
Input>keypress,Please Enter The Amount Of Times You Want The Mouse%CRLF%To Left Click Once You Press The Mouse Middle Button
If>%keypress%=,Exit
Label>WaitKey
WaitKeyDown>VK4
Let>num=0
Label>Press
LClick
Let>num=num+1
Wait>%wait%
If>%num%=%keypress%
Goto>WaitKey
Else
Goto>Press
Label>Exit View Snippet Page
Quick Updated Code While At Work. Hope It Helps.
Let>APP_TITLE=Mouse Press
Let>INPUT_BROWSE=0
Input>vWait,Please Enter The Amount Of Time You Want To Wait%CRLF%Before The Next Key Press (In Seconds) Example: 3 or 3.5
If>%vWait%=,Exit
Input>vKeyPress,Please Enter The Amount Of Times You Want The Mouse%CRLF%To Left Click Once You Press The Mouse Middle Button
If>%vKeyPress%=,Exit
Label>vWaitKey
WaitKeyDown>VK4
GoSub>Clicky
GoTo>vWaitKey
Label>Exit
SRT>Clicky
Let>vNum=0
While>vNum<>%vKeyPress%
Let>vNum=vNum+1
LClick
EndWhile
END>Clicky View Snippet Page
FIREFIGHTER