xShadowx Posted November 19, 2008 Share Posted November 19, 2008 I have been messing around with click boxes, but how would I make it so when I have the click box clicked and I press a (button) it will run a run command? I couldnt figure it out. All help is appreciated. Link to comment Share on other sites More sharing options...
martin Posted November 19, 2008 Share Posted November 19, 2008 I have been messing around with click boxes, but how would I make it so when I have the click box clicked and I press a (button) it will run a run command? I couldnt figure it out. All help is appreciated.$Msg = GuiGetMsg() Switch $Msg Case $btn1 if GuiCtrlRead($ChkBox1) = $GUI_CHECKED then Run(".... Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
xShadowx Posted November 19, 2008 Author Share Posted November 19, 2008 (edited) Is there a way to get an error to pop up if one of the check boxes arnt clicked? Edited November 19, 2008 by xShadowx Link to comment Share on other sites More sharing options...
rasim Posted November 19, 2008 Share Posted November 19, 2008 xShadowxShould to check so:#include <GuiConstantsEx.au3> $hGUI = GUICreate("Test", 200, 100) $checkbox = GUICtrlCreateCheckbox("Check me", 50, 25, 70, 15) $button = GUICtrlCreateButton("Test", 65, 66, 75, 23) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $button If BitAND(GUICtrlRead($checkbox), $GUI_CHECKED) Then ConsoleWrite("Checked" & @LF) Else ConsoleWrite("Unchecked" & @LF) EndIf EndSwitch WEndBecause the checkbox might have several states Link to comment Share on other sites More sharing options...
rasim Posted November 19, 2008 Share Posted November 19, 2008 Is there a way to get an error to pop up if one of the check boxes arnt clicked?You have not enough examples? Link to comment Share on other sites More sharing options...
xShadowx Posted November 19, 2008 Author Share Posted November 19, 2008 Sorry, im stupid with autoit, it just doesnt stick. Link to comment Share on other sites More sharing options...
martin Posted November 19, 2008 Share Posted November 19, 2008 xShadowx Should to check so: #include <GuiConstantsEx.au3> $hGUI = GUICreate("Test", 200, 100) $checkbox = GUICtrlCreateCheckbox("Check me", 50, 25, 70, 15) $button = GUICtrlCreateButton("Test", 65, 66, 75, 23) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $button If BitAND(GUICtrlRead($checkbox), $GUI_CHECKED) Then ConsoleWrite("Checked" & @LF) Else ConsoleWrite("Unchecked" & @LF) EndIf EndSwitch WEnd Because the checkbox might have several states Yes it could, and I've even told other people about that. Thanks rasim. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
xShadowx Posted November 20, 2008 Author Share Posted November 20, 2008 Thanks rasim, that worked great. Could I add multiple $""'s to it? Like: GUICtrlRead($checkbox, $checkbox1, $checkbox2) I have tryed using "," and "&". Link to comment Share on other sites More sharing options...
rasim Posted November 20, 2008 Share Posted November 20, 2008 Could I add multiple $""'s to it? Like: GUICtrlRead($checkbox, $checkbox1, $checkbox2) I have tryed using "," and "&".No, but if you have many checkbox controls, you can create a array with this controls and then check state of the each control in the loop. Link to comment Share on other sites More sharing options...
xShadowx Posted November 20, 2008 Author Share Posted November 20, 2008 As an array, do you mean having multiple of this? Case $button If BitAND(GUICtrlRead($checkbox), $GUI_CHECKED) Then ConsoleWrite("Checked" & @LF) Else ConsoleWrite("Unchecked" & @LF) EndIf Link to comment Share on other sites More sharing options...
rasim Posted November 20, 2008 Share Posted November 20, 2008 xShadowxExample:expandcollapse popup#include <GuiConstantsEx.au3> Dim $aCheckBox[10] Dim $left = 10, $right = 10 $hGUI = GUICreate("Test", 420, 160) For $i = 0 To UBound($aCheckBox) - 1 $aCheckBox[$i] = GUICtrlCreateCheckbox("Checkbox" & $i + 1, $left, $right, 80, 15) $left += 80 If $left >= 400 Then $left = 10 $right += 20 EndIf Next $CheckButton = GUICtrlCreateButton("Test", 11, 128, 75, 23) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $CheckButton _CheckedGet($aCheckBox) EndSwitch WEnd Func _CheckedGet($aControl) Local $i For $i = 0 To UBound($aControl) - 1 ConsoleWrite(GUICtrlRead($aControl[$i], 1) & " is checked: " & (BitAND(GUICtrlRead($aControl[$i]), $GUI_CHECKED) = $GUI_CHECKED) & @LF) Next EndFunc Link to comment Share on other sites More sharing options...
xShadowx Posted November 20, 2008 Author Share Posted November 20, 2008 So could I use that if I wanted, lets say, check box 1 to be clicked and it runs calculator, and check box 2 to be clicked and it runs winamp? Link to comment Share on other sites More sharing options...
rasim Posted November 21, 2008 Share Posted November 21, 2008 xShadowxHi. Your questions is very base and I am surprised why you can't find examples in the help file #include <GuiConstantsEx.au3> $hGUI = GUICreate("Test", 200, 100) $Calc_checkbox = GUICtrlCreateCheckbox("Calc", 11, 11, 50, 15) $Notepad_checkbox = GUICtrlCreateCheckbox("Notepad", 11, 36, 60, 15) $Regedit_checkbox = GUICtrlCreateCheckbox("Regedit", 11, 61, 65, 15) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Calc_checkbox If BitAND(GUICtrlRead($Calc_checkbox), $GUI_CHECKED) Then Run("calc.exe") Case $Notepad_checkbox If BitAND(GUICtrlRead($Notepad_checkbox), $GUI_CHECKED) Then Run("notepad.exe") Case $Regedit_checkbox If BitAND(GUICtrlRead($Regedit_checkbox), $GUI_CHECKED) Then Run("regedit.exe") EndSwitch WEnd Link to comment Share on other sites More sharing options...
xShadowx Posted November 21, 2008 Author Share Posted November 21, 2008 (edited) Thank you rasim, that worked perfectly. Now one question, I can use "GUI_UNCHECKED" as well, now how would I create an error if all of the boxes are unclicked. I have tryed messing around with it. I get an error once I get past $2, and its because of "BitAND".If BitAND(GUICtrlRead($1, $2), $GUI_UNCHECKED) Then Run("regedit.exe") Now is there a way to link all of the "$1, $2..." into one? Like This? $all = ($1, $2, $3, $4) I have been playing around with it, but I couldnt find out. Its probably something simple too. Edited November 21, 2008 by xShadowx Link to comment Share on other sites More sharing options...
rasim Posted November 22, 2008 Share Posted November 22, 2008 xShadowxIf BitAND(GUICtrlRead($1), $GUI_CHECKED) And BitAND(GUICtrlRead($2), $GUI_CHECKED) Then MsgBox(0, "MyProgram", "All checkboxs are checked") Else MsgBox(16, "MyProgram error", "Some checkboxs are not checked") EndIf Link to comment Share on other sites More sharing options...
martin Posted November 22, 2008 Share Posted November 22, 2008 xShadowx If BitAND(GUICtrlRead($1), $GUI_CHECKED) And BitAND(GUICtrlRead($2), $GUI_CHECKED) Then MsgBox(0, "MyProgram", "All checkboxs are checked") Else MsgBox(16, "MyProgram error", "Some checkboxs are not checked") EndIfI suppose you could have this to make it more compact, though it might look a bit strange. If BitAND(GUICtrlRead($1),GUICtrlRead($2),GUICtrlRead($3),GUICtrlRead($4), $GUI_CHECKED) Then MsgBox(0, "MyProgram", "All checkboxs are checked") Else MsgBox(16, "MyProgram error", "Some checkboxs are not checked") EndIf Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
rasim Posted November 22, 2008 Share Posted November 22, 2008 I suppose you could have this to make it more compact, though it might look a bit strange. If BitAND(GUICtrlRead($1),GUICtrlRead($2),GUICtrlRead($3),GUICtrlRead($4), $GUI_CHECKED) Then MsgBox(0, "MyProgram", "All checkboxs are checked") Else MsgBox(16, "MyProgram error", "Some checkboxs are not checked") EndIfYes, you are right, good and simple example Link to comment Share on other sites More sharing options...
xShadowx Posted November 22, 2008 Author Share Posted November 22, 2008 That worked PERFECTLY, thank you again martin. 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