How to skip ahead in a long script with hotkeys?
I have recorded this very long script with Feiyue's macro recorder to autofarm a game. I have noticed that sometimes the script fails due to latency or other issues. I want to add hotkeys where I can skip ahead to certain parts of the script so it can continue autofarming past areas it already completed.
I have tried Goto with labels, but get this error message "A Goto/Gosub must not jump into a block that doesn't enclose it".
Is there an easy way to implement this without having to change my script into alot of functions? Or perhaps I need to separate all the regions into their own functions, and call them in the main loop.
Really appreciate any feedback. Thanks.
This is a gist of my script so far
Playspeed:=1
Loop, 1
{
SetTitleMatchMode, 2
CoordMode, Mouse, Window
tt = ahk_exe Game.exe
WinWait, %tt%
IfWinNotActive, %tt%,, WinActivate, %tt%
RegionOneLabel:
; very long sequence for region one
RegionTwoLabel:
; very long sequence for region two
RegionThreeLabel:
; very long sequence for region three
Sleep, % 10000
Run taskkill.exe /f /im "Game.exe"
ExitApp
}
F5::
Goto, RegionOneLabel
return
F6::
Goto, RegionTwoLabel
return
F7::
Goto, RegionThreeLabel
return