Macro stops working after GoSub is executed
Moderators: Dorian (MJT support), JRL
Macro stops working after GoSub is executed
I am using windows 7 . Every time i run my macro it works well until it reaches part where it goes GoSub, after GoSub part of code is executed the macro stops working as if someone clicked stop, and the rest of my code doesn't get executed. Is that some kind of bug ? I was running code with GoSub in it on windows xp like 2 years ago and it worked, am wondering why its not working now. is there any alternative to GoSub i don't know it works on windows 7.
Re: Macro stops working after GoSub is executed
Hi, Should work. Can you post an example where it does not work.
Re: Macro stops working after GoSub is executed
I am using Macro Scheduler 11 maybe i need to upgrade it.
These are mine GoSubs executors
These are mine GoSubs executors
Code: Select all
Let>a=0
Repeat>a
Let>a=a+1
// 1
MouseMove>280,1900
wait 5
LClick
wait 1
MouseMove>130,1800
wait 2
LClick
wait 2
GoSub>fight
wait 1
// 2
MouseMove>280,1900
wait 5
LClick
wait 1
MouseMove>340,1800
wait 2
LClick
wait 2
GoSub>fight
wait 1
// 3
MouseMove>280,1900
wait 5
LClick
wait 1
MouseMove>560,1800
wait 2
LClick
wait 2
GoSub>fight
wait 1
// 4
MouseMove>280,1900
wait 5
LClick
wait 1
MouseMove>770,1800
wait 2
LClick
wait 2
GoSub>fight
wait 1
// 5
MouseMove>280,1900
wait 5
LClick
wait 1
MouseMove>1000,1800
wait 2
LClick
wait 2
GoSub>fight
wait 600
Until>a>5
Last edited by Hunkel on Wed Oct 07, 2015 4:37 pm, edited 1 time in total.
Re: Macro stops working after GoSub is executed
Hi, One thing I note in the SRT is that you have wait 10, instead of wait>10. That will cause it to hang.
Re: Macro stops working after GoSub is executed
Mine first GoSub code gets executed and is working properly. Problem starts after my first GoSub code ends, my macro then stops and is not executing any more code.
I changed wait 10 to wait>10 to see if i will get any difference but it doesn't make no difference i still have the same problem.
I changed wait 10 to wait>10 to see if i will get any difference but it doesn't make no difference i still have the same problem.
Re: Macro stops working after GoSub is executed
Ok i just added number 1 to my GoSub name and changed it from srt>fight to srt>fight1 and is working now. Could be bug due to short name or lacking a number in it.
Re: Macro stops working after GoSub is executed
Hi, great that it now works (although not fully sure what caused the problem). Sorry, I was mistaken, wait 10 seems to work fine.
Re: Macro stops working after GoSub is executed
Without seeing the rest of your code my guess would be you have a variable named "fight" somewhere in the script. When "fight" has a value and you do a GoSub>fight, you are trying to go to a subroutine with a name that is the value of the variable.
Code: Select all
GoSub>fight
Let>fight=1
GoSub>fight
SRT>fight
MDL>fight found
END>fight
Re: Macro stops working after GoSub is executed
I do have a image finder named fight it might be that
Code: Select all
GetScreenRes>sX,sY
ScreenCapture>0,0,sX,sY,C:\Programs\Macro Scheduler 11\scre\screen.bmp
FindImagePos>C:\Programs\Macro Scheduler 11\pictures\fight.bmp,C:\Programs\Macro Scheduler 11\scre\screen.bmp,60,1,XPos,YPos,fight
MouseMove>XPos_0,YPos_0
Re: Macro stops working after GoSub is executed
You got it!
As soon as you run that FindImagePos> line the term "fight" is assigned a value (the number of images found). Once "fight" has a value, it is no longer useful as a subroutine name.
As soon as you run that FindImagePos> line the term "fight" is assigned a value (the number of images found). Once "fight" has a value, it is no longer useful as a subroutine name.
- AntoniusMomac
- Junior Coder
- Posts: 20
- Joined: Fri Dec 07, 2007 7:46 am
- Location: New York City, NY
Re: Macro stops working after GoSub is executed
JRL,
I've been doing this for awhile now and totally made that mistake. In fact, until reading your answer I totally overlooked the possibility of making such a silly mistake . Variable naming 101, sign me up.
Thank you so much for your help. It was brilliant.
I've been doing this for awhile now and totally made that mistake. In fact, until reading your answer I totally overlooked the possibility of making such a silly mistake . Variable naming 101, sign me up.
Thank you so much for your help. It was brilliant.
Love Simple!! "Simplicity means the achievement of maximum effect with minimum means" - Dr. Koichi Kawana, Architect, designed the botanical gardens
Re: Macro stops working after GoSub is executed
Another time-saving troubleshooting technique is to insert **BREAKPOINT** (case insensitive) at the line of interest.
Code: Select all
GetScreenRes>sX,sY
**BREAKPOINT**
ScreenCapture>0,0,sX,sY,C:\Programs\Macro Scheduler 11\scre\screen.bmp
FindImagePos>C:\Programs\Macro Scheduler 11\pictures\fight.bmp,C:\Programs\Macro Scheduler 11\scre\screen.bmp,60,1,XPos,YPos,fight
MouseMove>XPos_0,YPos_0
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Macro stops working after GoSub is executed
Hi Grovkillen,
Thank you for referring to the extremely valuable thread. It's my first time to become aware that MS can call dynamically-naming subroutines.Grovkillen wrote:Please feel free to use my script to find duplicates (post no. 6).
viewtopic.php?f=2&t=7733
Code: Select all
Let>I=2
Let>TEST={if(%I%=1,"Heaven","Hell")}
Gosub>%TEST%
SRT>Heaven
MDL>Heaven
END>Heaven
SRT>Hell
MDL>Hell
END>Hell
Re: Macro stops working after GoSub is executed
Hi Grovkillen,
Thank you for sharing your debugging script with us.
Your script is absolutely useful in creating a list of variables and their occurrences. Hope Macro Scheduler will include your debugging tool in the future.Grovkillen wrote:Please feel free to use my script to find duplicates (post no. 6).
viewtopic.php?f=2&t=7733
Thank you for sharing your debugging script with us.