Hok Posted May 15, 2008 Share Posted May 15, 2008 #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: Henry OS: WinXP#ce ----------------------------------------------------------------------------; Script Start - Add your code below here#include <GUIConstants.au3>$Random=Random(1,100,1)#Region ### START Koda GUI section ### Form=C:\Documents and Settings\hdixon\Desktop\AUTOIT PROGRAMMING\KODA\Guess My Number.kxf$Form1 = GUICreate("Guess my Number", 401, 230, 193, 125)GUISetBkColor(0xFFFFFF)$Input1 = GUICtrlCreateInput("", 0, 56, 393, 21)GUICtrlSetTip(-1, "Enter your guess here")$Label1 = GUICtrlCreateLabel("Enter Your Guess Here:", 0, 0, 352, 48)GUICtrlSetFont(-1, 26, 800, 0, "Adobe Garamond Pro")$Button1 = GUICtrlCreateButton("Guess!", 0, 88, 195, 73, 0)GUICtrlSetFont(-1, 22, 800, 0, "Waltography MV")$Button2 = GUICtrlCreateButton("Credits", 200, 88, 193, 73, 0)GUICtrlSetFont(-1, 18, 800, 0, "Walt Disney Script")$Label2 = GUICtrlCreateLabel("Status:", 8, 168, 376, 48)GUICtrlSetFont(-1, 15, 800, 0, "Toxica")GUISetState(@SW_SHOW)#EndRegion ### END Koda GUI section ###While 1$nMsg = GUIGetMsg()Switch $nMsgCase $GUI_EVENT_CLOSEExitCase $Button2 MsgBox(0, "Credits", "Scripting: Henry Dixon (^^)")Case $Button1 Test()EndSwitchWEndFunc Test() $Counter=0 $Guess=GUICtrlRead($input1) If $guess< $Random Then $Label2 = GUICtrlCreateLabel("Status: The Number is Lower!", 8, 168, 376, 48)GUICtrlSetFont(-1, 15, 800, 0, "Toxica")$Counter=$Counter+1 EndIf If $guess> $Random Then $Label2 = GUICtrlCreateLabel("Status: The Number is Higher!", 8, 168, 376, 48)GUICtrlSetFont(-1, 15, 800, 0, "Toxica")$Counter=$Counter+1 EndIf If $guess=$Random Then $Counter=$Counter+1 $Label2 = GUICtrlCreateLabel("Nice! You got it! It took you " &$counter &" tries", 8, 168, 376, 48)GUICtrlSetFont(-1, 15, 800, 0, "Toxica") EndIf EndFuncIs there any GUILabelKill command or anything to kill the label when I am done with it??? I try typing 100 and it says Status: The number is lower! but then I type in 1 and press the button and it says the same thing... Link to comment Share on other sites More sharing options...
newbiescripter Posted May 15, 2008 Share Posted May 15, 2008 (edited) Use: GUICtrlSetData ( controlID, data [, default] ) EDIT: You should change the labels: If $guess < $Random Then $Label2 = GUICtrlCreateLabel("Status: The Number is Higher!", 8, 168, 376, 48) If $guess > $Random Then $Label2 = GUICtrlCreateLabel("Status: The Number is Lower!", 8, 168, 376, 48) Or els it will not be right.. try type in 1 and see that is says that the number is lower which is wrong EDIT: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: Henry OS: WinXP #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstants.au3> $Random=Random(1,100,1) #Region ### START Koda GUI section ### Form=C:\Documents and Settings\hdixon\Desktop\AUTOIT PROGRAMMING\KODA\Guess My Number.kxf $Form1 = GUICreate("Guess my Number", 401, 230, 193, 125) GUISetBkColor(0xFFFFFF) $Input1 = GUICtrlCreateInput("", 0, 56, 393, 21) GUICtrlSetTip(-1, "Enter your guess here") $Label1 = GUICtrlCreateLabel("Enter Your Guess Here:", 0, 0, 352, 48) GUICtrlSetFont(-1, 26, 800, 0, "Adobe Garamond Pro") $Button1 = GUICtrlCreateButton("Guess!", 0, 88, 195, 73, 0) GUICtrlSetFont(-1, 22, 800, 0, "Waltography MV") $Button2 = GUICtrlCreateButton("Credits", 200, 88, 193, 73, 0) GUICtrlSetFont(-1, 18, 800, 0, "Walt Disney Script") $Label2 = GUICtrlCreateLabel("Status:", 8, 168, 376, 48) GUICtrlSetFont(-1, 15, 800, 0, "Toxica") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $Counter=1 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button2 MsgBox(0, "Credits", "Scripting: Henry Dixon (^^)") Case $Button1 Test() sleep(1500) GUICtrlSetData($Label2,"Status: Try guessing a new number!") Sleep(1500) GUICtrlSetData($Label2,"Status:") EndSwitch WEnd Func Test() $Guess=GUICtrlRead($input1) Select Case ($guess > $Random) $Label2 = GUICtrlCreateLabel("Status: The Number is Lower!", 8, 168, 376, 48) GUICtrlSetFont(-1, 15, 800, 0, "Toxica") $Counter=$Counter+1 Case ($guess < $Random) $Label2 = GUICtrlCreateLabel("Status: The Number is Higher!", 8, 168, 376, 48) GUICtrlSetFont(-1, 15, 800, 0, "Toxica") $Counter=$Counter+1 Case ($guess == $Random) $Label2 = GUICtrlCreateLabel("Nice! You got it! It took you " &$counter &" tries", 8, 168, 376, 48) GUICtrlSetFont(-1, 15, 800, 0, "Toxica") $Counter=$Counter+1 Sleep(2000) EndSelect EndFunc; Test() The above is a little quick example, but you can do it in a smarter way Edited May 16, 2008 by newbiescripter Link to comment Share on other sites More sharing options...
Hiyoal Posted May 19, 2008 Share Posted May 19, 2008 To Kill or "destroy" a control, use GUICtrlDelete(), or else, use GUICtrlSetData to set it to "". Also, Globally declare $Counter=0 at the start of the script to not limit the variable in the control. It wasnt working properly before. Hiyoal Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now