Jump to content

Can't exit program


moejo
 Share

Recommended Posts

Can anyone help me try to exit this program? The exit button won't work when the other buttons have been clicked. The exit button only works when it is the first button clicked.

Sorry for the mess in the scripting!

Summary of the script: Each button searches for a specific color and clicks on it every so often. [i bolded the part where the script begins to quit]

-----------------------------------------------------------------------------------------------------------------------------

#include <GUIConstants.au3>

GUICreate("War", 265, 150, -1, -1)

$button1= GUICtrlCreateButton("B2", 30, 10, 200, 30)

$button2= GUICtrlCreateButton("B1", 30, 45, 200, 30)

$button3= GUICtrlCreateButton("Quit", 30, 115, 200, 30)

GuiSetState ()

While 1

$msg = GUIGetMsg()

$a = Random ( 45000, 540000, 1 )

$b = Random ( 170000, 180000, 1 )

Select

Case $msg = $button1

While 1 = 1

WinActivate ( "War" )

$coord = PixelSearch( 348, 0, 407, 570, 0xFFBF00)

If Not @error Then

MouseClick("left", $coord[0], $coord[1], 1)

Sleep ( $a )

Else

MsgBox( 0, "Color", "No Color Found")

EndIf

WEnd

Case $msg = $button2

While 1 = 1

WinActivate ( "War" )

$coord = PixelSearch( 310, 0, 370, 578, 0xFFBF00)

If Not @error Then

MouseClick("left", $coord[0], $coord[1], 1)

Sleep ( $b )

Else

MsgBox( 0, "Color", "No Color Found")

Exit

EndIf

WEnd

Case $msg = $button3

If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer

$iMsgBoxAnswer = MsgBox(4,"Quit","Are you sure?")

Select

Case $iMsgBoxAnswer = 6 ;Yes

Exit

Case $iMsgBoxAnswer = 7 ;No

EndSelect

EndSelect

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

Edited by moejo
Link to comment
Share on other sites

might try something like

#include <GUIConstants.au3>

GUICreate("War", 265, 150, -1, -1)

$button1 = GUICtrlCreateButton("B2", 30, 10, 200, 30)
$button2 = GUICtrlCreateButton("B1", 30, 45, 200, 30)
$button3 = GUICtrlCreateButton("Quit", 30, 115, 200, 30)
GUISetState()


While 1
    $msg = GUIGetMsg()
    $a = Random(45000, 540000, 1)
    $b = Random(170000, 180000, 1)
    
    Select
        
        Case $msg = $button1
            _War()
            AdlibEnable("_War", $a)
            
        Case $msg = $button2
            _War()
            AdlibEnable("_War", $B)
            
        Case $msg = $button3
            If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer
            $iMsgBoxAnswer = MsgBox(4, "Quit", "Are you sure?")
            Select
                Case $iMsgBoxAnswer = 6 ;Yes
                    Exit
                Case $iMsgBoxAnswer = 7 ;No
            EndSelect
            
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

Func _War()
    WinActivate("War")
    $coord = PixelSearch(348, 0, 407, 570, 0xFFBF00)
    If Not @error Then
        MouseClick("left", $coord[0], $coord[1], 1)
    Else
        MsgBox(0, "Color", "No Color Found")
    EndIf
EndFunc   ;==>_War

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

might try something like

#include <GUIConstants.au3>

GUICreate("War", 265, 150, -1, -1)

$button1 = GUICtrlCreateButton("B2", 30, 10, 200, 30)
$button2 = GUICtrlCreateButton("B1", 30, 45, 200, 30)
$button3 = GUICtrlCreateButton("Quit", 30, 115, 200, 30)
GUISetState()
While 1
    $msg = GUIGetMsg()
    $a = Random(45000, 540000, 1)
    $b = Random(170000, 180000, 1)
    
    Select
        
        Case $msg = $button1
            _War()
            AdlibEnable("_War", $a)
            
        Case $msg = $button2
            _War()
            AdlibEnable("_War", $B)
            
        Case $msg = $button3
            If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer
            $iMsgBoxAnswer = MsgBox(4, "Quit", "Are you sure?")
            Select
                Case $iMsgBoxAnswer = 6 ;Yes
                    Exit
                Case $iMsgBoxAnswer = 7 ;No
            EndSelect
            
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

Func _War()
    WinActivate("War")
    $coord = PixelSearch(348, 0, 407, 570, 0xFFBF00)
    If Not @error Then
        MouseClick("left", $coord[0], $coord[1], 1)
    Else
        MsgBox(0, "Color", "No Color Found")
    EndIf
EndFunc   ;==>_War
Hmm... I copied and pasted, and it still doesn't quit while one the buttons are presed first. Thanks for taking a shot at it :whistle: Edited by moejo
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...