Jump to content

Ending Script in a Loop


Recommended Posts

I'm having issues where I can't exit my code without ending the process.

Heres a quick snippet of my code.

After I select the radio button, it needs to continuously check Func Himes()

Thanks for your help

GUI()

Func GUI()
    Local $radio1, $radio2, $radio3, $radio4, $radio5, $radio6, $radio7, $radio8, _
            $radio9, $radio10, $radio11, $radio12, $radio13, $radio14, $radio15, $msg
    GUICreate($login, 180, 460)

$radio1 = GUICtrlCreateRadio("Encounter with the Buddha", 10, 10, 170, 20)

GUISetState()

While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
                Himes()
        EndSelect
    WEnd
EndFunc 

Func Himes()
    While 1
        getMapID()
        ;Himes
        If $mapID = 800020120 Then
            ControlClick("GMS", $login, "[CLASS:Static; INSTANCE:52]")
            ControlSetText("bRush", "", "[CLASS:Edit; INSTANCE:2]", "800020130")
            ControlClick("bRush", "", "[CLASS:Button; INSTANCE:1]")
            ControlClick("GMS", $login, "[CLASS:Static; INSTANCE:52]")
            Sleep(10000)
        EndIf
    WEnd
EndFunc   ;==>Himes
Edited by brandonms
Link to comment
Share on other sites

For example:

GUI()

Func GUI()
    Local $radio1, $radio2, $radio3, $radio4, $radio5, $radio6, $radio7, $radio8, _
            $radio9, $radio10, $radio11, $radio12, $radio13, $radio14, $radio15, $msg
    GUICreate($login, 180, 460)

    $radio1 = GUICtrlCreateRadio("Encounter with the Buddha", 10, 10, 170, 20)

    GUISetState()
    
    $doHimes = False

    While 1
            $msg = GUIGetMsg()
            Select
                Case $msg = $GUI_EVENT_CLOSE
                    ExitLoop
                Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
                    $doHimes = True
            EndSelect
        WEnd
        If $doHimes Then
            Himes()
        EndIf
    WEnd
EndFunc 

Func Himes()
    getMapID()
    ;Himes
    If $mapID = 800020120 Then
        ControlClick("GMS", $login, "[CLASS:Static; INSTANCE:52]")
        ControlSetText("bRush", "", "[CLASS:Edit; INSTANCE:2]", "800020130")
        ControlClick("bRush", "", "[CLASS:Button; INSTANCE:1]")
        ControlClick("GMS", $login, "[CLASS:Static; INSTANCE:52]")
        Sleep(10000)
    EndIf
EndFunc   ;==>Himes

Or you can do GUIGetMsg in Func Himes() and handle them.

Link to comment
Share on other sites

Now I'm having an issue where if switch from Himes() to a second fuction, it keeps looping Himes()

I'm guessing that I would be better off using a check box?

Whats with all the loops? you dont need to check for a msg from $radio1 AND check if its checked, just check for the last.

GUI()
Func GUI()
    Local $radio1, $radio2, $radio3, $radio4, $radio5, $radio6, $radio7, $radio8, _
            $radio9, $radio10, $radio11, $radio12, $radio13, $radio14, $radio15, $msg
    GUICreate($login, 180, 460)

$radio1 = GUICtrlCreateRadio("Encounter with the Buddha", 10, 10, 170, 20)

GUISetState()

While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case GUICtrlRead($radio1) = $GUI_CHECKED
                Himes()
        EndSelect
    WEnd
EndFunc 

Func Himes()
         getMapID()
        ;Himes
        If $mapID = 800020120 Then
            ControlClick("GMS", $login, "[CLASS:Static; INSTANCE:52]")
            ControlSetText("bRush", "", "[CLASS:Edit; INSTANCE:2]", "800020130")
            ControlClick("bRush", "", "[CLASS:Button; INSTANCE:1]")
            ControlClick("GMS", $login, "[CLASS:Static; INSTANCE:52]")
            Sleep(10000)
        EndIf
EndFunc   ;==>Himes

As for your second problem i suppose in the full script that other function is called in the same select sequense? if so it doesnt get checked when the checkbox is checked.

GUI()
Func GUI()
    Local $radio1, $radio2, $radio3, $radio4, $radio5, $radio6, $radio7, $radio8, _
            $radio9, $radio10, $radio11, $radio12, $radio13, $radio14, $radio15, $msg
    GUICreate($login, 180, 460)

    $radio1 = GUICtrlCreateRadio("Encounter with the Buddha", 10, 10, 170, 20)

    GUISetState()

    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If GUICtrlRead($radio1) = $GUI_CHECKED Then Himes()
    WEnd
EndFunc   ;==>GUI

Func Himes()
    getMapID()
    ;Himes
    If $mapID = 800020120 Then
        ControlClick("GMS", $login, "[CLASS:Static; INSTANCE:52]")
        ControlSetText("bRush", "", "[CLASS:Edit; INSTANCE:2]", "800020130")
        ControlClick("bRush", "", "[CLASS:Button; INSTANCE:1]")
        ControlClick("GMS", $login, "[CLASS:Static; INSTANCE:52]")
        Sleep(10000)
    EndIf
EndFunc   ;==>Himes

or something like that

Edited by Djarlo
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...