moejo 0 Report post Posted August 10, 2006 (edited) 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 )SelectCase $msg = $button1While 1 = 1WinActivate ( "War" )$coord = PixelSearch( 348, 0, 407, 570, 0xFFBF00)If Not @error ThenMouseClick("left", $coord[0], $coord[1], 1)Sleep ( $a )ElseMsgBox( 0, "Color", "No Color Found")EndIfWEndCase $msg = $button2While 1 = 1WinActivate ( "War" )$coord = PixelSearch( 310, 0, 370, 578, 0xFFBF00)If Not @error ThenMouseClick("left", $coord[0], $coord[1], 1)Sleep ( $b )ElseMsgBox( 0, "Color", "No Color Found")ExitEndIfWEndCase $msg = $button3If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer$iMsgBoxAnswer = MsgBox(4,"Quit","Are you sure?")SelectCase $iMsgBoxAnswer = 6 ;YesExitCase $iMsgBoxAnswer = 7 ;NoEndSelect EndSelectIf $msg = $GUI_EVENT_CLOSE Then ExitLoopWend Edited August 10, 2006 by moejo Share this post Link to post Share on other sites
GaryFrost 11 Report post Posted August 10, 2006 might try something like expandcollapse popup#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. Share this post Link to post Share on other sites
moejo 0 Report post Posted August 10, 2006 (edited) might try something like expandcollapse popup#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 Edited August 10, 2006 by moejo Share this post Link to post Share on other sites
moejo 0 Report post Posted August 10, 2006 I found out that because if one button is set in motion, the other buttons won't work. Now what I want to know is how to interrupt the button's loop so other buttons can be clicked. :S Share this post Link to post Share on other sites