Labelling - user issue, not software issue.

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
aglanija
Newbie
Posts: 6
Joined: Tue Mar 16, 2021 10:09 am

Labelling - user issue, not software issue.

Post by aglanija » Wed Jun 02, 2021 12:26 am

Hello.

I am struggling with to understand how to jump between labels, in what, by my standards, is quite a convoluted process.

To cut a long story relatively short, I am trying to force a video game to do the following:

1) Load the game into what I'll call its initial configuration - label LOAD.
2) Change some aspect of the game so that it's in what I'll call Configuration 1 - label MOUSE.
3) When it's in Configuration 1, force the computer to play against itself - label GAME.
4) Save a print screen of some information about Configuration 1.
5) Repeat step 1 - so, when the print screen has been dumped in the folder, load the game, and then...
5) Repeat steps 3 and 4 for x amount of times.
6) Change some aspect of the game so that it's in what I'll call Configuration 2.

...


It isn't working properly. I can't get it to the stage where x number of repetitions of Configuration 1 are completed, with the game being loaded into its initial state after each repetition, and then Configuration 2 is loaded.

What am I doing wrong, please? The individual bits, taken in isolation, work - so, it loads, I can mouse-move to force it to change configuration, I can print-screen, etc, but the whole thing doesn't work together.

Obviously, any help you can give me will be hugely appreciated.

This is how my code looks:

'THIS LOADS THE GAME
'Set the focus to FM21
SetFocus>Football Manager 2021

Wait>2

Let>k=0
Let>counter=1
Goto>Load
Label>Load

'Make a loop, both for the overall repetition of the matches, and for the iteration of the filenames
Wait>2

'Click 'FM' button
MouseMove>3235,71
LClick
Wait>2
'Click` 'Load Game' button
MouseMove>3376,277
LClick
Wait>2
'Click 'Do Not Save Game' button
MouseMove>2086,1189
LClick
Wait>2
'Select one of the games to load
MouseMove>1345,863
LDblClick
Wait>2

'Hit continue
MouseMove>3616,61
LClick
Wait>2

'THE GAME HAS BEEN LOADED'
'NEXT, CHANGE THE FORMATION

Label>start

SetFocus>Football Manager 2021
Wait>2
'Move mouse around and click through to (home) manager's preferred formation.
MouseMove>1117,84
LClick
Wait>2
MouseMove>1134,77
LClick
Wait>2
MouseMove>767,915
LClick
Wait>2
MouseMove>1545, 160
LClick
Wait>2
MouseMove>1572,275
LClick
Wait>2
MouseMove>1602,415
LClick
Wait>2
MouseMove>2944,90
LClick
Wait>2
MouseMove>3039,607
LClick
Wait>2
Goto>mouse
Label>mouse
'Set variable for mouse move
Let>init=1270
Let>pixels1=counter*70
Let>pixels2=pixels1+init
LClick
MouseMove>2300,init
LClick
Wait>2
MouseMove>2300,pixels2
LClick
Wait>2
MouseMove>2846,1786
LClick
Wait>2
Press CTRL
Send>s
Release CTRL
Wait>2

'Preparing for screen dump
HoldKey>VK_SHIFT,1000,0,0
Send>A
ReleaseKey>SHIFT
Wait>2

'Press OK when asked to print screen
MouseMove>2124,1241
LClick
Wait>2
'Locate Save As box
MouseMove>1929,630
LClick
Wait>2
'Delete contents of Save As box
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Wait>2
'Make new filename
Send> formation_%counter%
wait>2
Press ENTER
Let>k=k+1
Wait>1

Press CTRL
Send>s
Release CTRL

If>k<3
Goto>game
Else
Goto>start
Endif

Goto>game

Label>game
'Hit continue
MouseMove>3616,61
LClick
Wait>4
'Hit continue again
LClick
Wait>4
'Click name of league at top of screen
MouseMove>1186,92
LClick
Wait>4

'Click Team Opposition Test
MouseMove>713,907
LClick
Wait>3
'Select schedule
MouseMove>1140,170
Wait>2
LClick
Wait>3
'Click Senior Squad schedule
MouseMove>1160,240
LClick
Wait>3

'Click the match report
MouseMove>1989,493
LClick
Wait>2
'Preparing for screen dump
HoldKey>VK_SHIFT,1000,0,0
Send>A
ReleaseKey>SHIFT
Wait>2
'Press OK when asked to print screen
MouseMove>2124,1241
LClick
Wait>2

'Locate Save As box
MouseMove>1929,630
LClick
Wait>2
'Delete contents of Save As box
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Wait>2
'Make new filename
Send> matchreport_%counter%_%k%
wait>2
Press ENTER

'Hit the back button
MouseMove>60,37
LClick
Wait>2
'You're now back on the fixtures screen - print it
'Preparing for screen dump
HoldKey>VK_SHIFT,1000,0,0
Send>A
ReleaseKey>SHIFT
Wait>2
'Press OK when asked to print screen
MouseMove>2124,1241
LClick
Wait>2
'Locate Save As box
MouseMove>1929,630
LClick
Wait>2

'Delete contents of Save As box
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Press BACKSPACE
Wait>2

'Make new filename
Send> scoreline_%counter%_%k%
wait>2
Press ENTER
'Hit the back button
MouseMove>414,50
LClick
Wait>2
If>counter<3
Goto>Load
Else Goto>start
Wait>2
Endif

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1386
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Labelling - user issue, not software issue.

Post by Dorian (MJT support) » Wed Jun 02, 2021 6:14 pm

Just something that isn't going to affect your script, but is redundant..

You don't need a Goto just before the label.

Code: Select all

Goto>Load
Label>Load
All you need is the label. You're telling the script to go to a label which is on the next line anyway.

You don't appear to need these lines at all. you only need a label if you want to jump to it from somewhere else. But I don't see a goto>mouse anywhere else in your script.

Code: Select all

Goto>mouse
Label>mouse
Near the bottom you have this :

Code: Select all

If>counter<3
Goto>Load
Else Goto>start
Wait>2
Endif
The correct usage would be :

Code: Select all

If>counter<3
Goto>Load
Else
Goto>start
Wait>2
Endif
You've created an infinite loop, as you've set counter=1, then later you have if>counter<3, but you don't have let>counter=counter+1 anywhere. So it'll always be 1.

Goto>Game is also redundant as your label is directly below. You want it to jump to start if it isn't <3, but just carry on if it is.

Code: Select all

If>k<3
Goto>game
Else
Goto>start
Endif
Goto>game
Label>game

Code: Select all

If>k<3
Else
Goto>start
Endif
Label>game
Or in other words.. if k is 0,1, or 2, carry on as normal, but if it's >2, go to start. So:

Code: Select all

If>k>2
Goto>start
Endif
Label>game
It's probably worth looking at the usage examples in Help. If you press F1 on any command you'll get context sensitive help for that command. There's also a command reference here.

It's probably worth running it through line by line just to see where it's failing, just to give you a good starting point. Break it down into chunks again and build it up again slowly.
Yes, we have a Custom Scripting Service. Message me or go here

aglanija
Newbie
Posts: 6
Joined: Tue Mar 16, 2021 10:09 am

Re: Labelling - user issue, not software issue.

Post by aglanija » Wed Jun 02, 2021 11:27 pm

Thanks for your advice.

I'll take a look at the extraneous labels, and I'll try to run it in chunks.

I appreciate your help!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts