'How to make this code recognize that it did not fulfill its function?, and return to another function, for example a -> inqueue:

when it doesn't open the game window, the code gets stuck at -> GamestepDisplay("Waiting for Game to start...") I need it to recognize that and return to another function which would be -> inqueue:

        loop
        {
            GamestepDisplay("Waiting for Game to start...")
            WinActivate, League of Legends ahk_exe LeagueClientUx.exe
            sleep 250
            HumanClickL(470, 360) ;click Reconnect button (even if not present)
            WinActivate, League of Legends (TM) Client ahk_exe League of Legends.exe
            sleep 250
            if QueueCheck()=1
            {
                goto, inqueue
            }
            if QueueCheck()=2
            {
                goto, startqueue
            }
            CoordMode, Mouse, Screen
            mousemove, A_ScreenWidth/2, A_ScreenHeight/2
            click, Right
            CoordMode, Mouse, Relative
            PixelSearch, ci, di, 137, 0, 137, 0, 0xceae63, 5, Fast RGB
            if ErrorLevel=0
            {
                WinActivate, League of Legends (TM) Client ahk_exe League of Legends.exe
                    SleepRandom(150)
                    goto, ingame
            }
            if ErrorLevel=1
            {
                SleepRandom(4000)
            }
        }
    }
    Else
    {
        Loop
        {
            if QueueCheck()=1
            {
                goto, inqueue
            }
            if QueueCheck()=2
            {
                goto, startqueue
            }
        }
    }

she asks me



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source