snoopy Posted January 28, 2009 Share Posted January 28, 2009 (edited) Hellow its me again -.- Wondering how can i make that there is only 1 choice out of 4 checkboxes e.g. you have 4 check boxes and you cant tick them all. in my case you can and i dont want it to be like that . expandcollapse popup[/autoit] code: #include <GUIConstants.au3> Global $f_Run = False, $f_AnyChecked = False Global $Form1 = GUICreate("Form1", 625, 444, 189, 146) $Pic1 = GUICtrlCreatePic("C:\Users\Snoopy\Desktop\toontown%20awesome%20picture.jpg", 0, 0, 625, 441, 0) GUISetState($GUI_DISABLE) GuiCtrlSetState($pic1, $GUI_DISABLE) Global $Credits = GUICtrlCreateButton("Credits", 0, 0, 153, 65, 0) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") Global $MyButton1 = GUICtrlCreateButton("Start", 520, 0, 100, 30, 0) GUICtrlSetFont(-1, 15, 800, 0, "MS Serif") GUICtrlSetBkColor(-1, 0xFFFFE1) Global $CheckBox1 = GUICtrlCreateCheckbox("Jump", 520, 32, 100, 30, 0) Global $CheckBox2 = GUICtrlCreateCheckbox("Beg", 520, 72, 100, 30, 0) Global $CheckBox3 = GUICtrlCreateCheckbox("Say", 520, 112, 100, 30, 0) Global $CheckBox4 = GUICtrlCreateCheckbox("Roallover", 520, 160, 100, 30, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Credits MsgBox(64, "Credits", "Matthew Povolotski, Toon:Sniffy Macnose") Case $MyButton1 HotKeySet("{F5}", "_StopIt") $f_Run = True While $f_Run $f_AnyChecked = False If BitAND(GUICtrlRead($CheckBox1), $GUI_CHECKED) Then $f_AnyChecked = True Local $randomcoords[7][2] = [[217,65],[228,79],[173,81],[223,93],[190,110],[214,112],[255,138]] MouseClick("left", 57, 45, 1) MouseClick("left", 127, 61, 1) $r = Random(0,6,1) MouseClick("left", $randomcoords[$r][0], $randomcoords[$r][1], 1) EndIf If BitAND(GUICtrlRead($CheckBox2), $GUI_CHECKED) Then $f_AnyChecked = True Local $randomcoords[7][2] = [[217,75],[228,79],[173,81],[223,93],[190,110],[214,112],[255,138]] MouseClick("left", 57, 45, 1) MouseClick("left", 127, 61, 1) $r = Random(0,6,1) MouseClick("left", $randomcoords[$r][0], $randomcoords[$r][1], 1) EndIf If BitAND(GUICtrlRead($CheckBox3), $GUI_CHECKED) Then $f_AnyChecked = True MsgBox(64, "Checkbox 3", "CheckBox 3 is checked", 1) EndIf If BitAND(GUICtrlRead($CheckBox4), $GUI_CHECKED) Then $f_AnyChecked = True MsgBox(64, "Checkbox 4", "CheckBox 4 is checked", 1) EndIf If Not $f_AnyChecked Then ExitLoop WEnd HotKeySet("{F5}") EndSwitch WEnd Func _StopIt() $f_Run = False EndFunc Edited January 28, 2009 by snoopy Link to comment Share on other sites More sharing options...
Manjish Posted January 28, 2009 Share Posted January 28, 2009 then use a radio button instead!! [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
KaFu Posted January 28, 2009 Share Posted January 28, 2009 This can be solved be enclosing the controls with dummys and then loop through the states using WM_COMMAND. expandcollapse popup#include <GUIConstants.au3> #include<WindowsConstants.au3> Global $f_Run = False, $f_AnyChecked = False Global $Form1 = GUICreate("Form1", 625, 444, 189, 146) $Pic1 = GUICtrlCreatePic("C:\Users\Snoopy\Desktop\toontown%20awesome%20picture.jpg", 0, 0, 625, 441, 0) GUISetState($GUI_DISABLE) GuiCtrlSetState($pic1, $GUI_DISABLE) Global $Credits = GUICtrlCreateButton("Credits", 0, 0, 153, 65, 0) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") Global $MyButton1 = GUICtrlCreateButton("Start", 520, 0, 100, 30, 0) GUICtrlSetFont(-1, 15, 800, 0, "MS Serif") GUICtrlSetBkColor(-1, 0xFFFFE1) $checkbox_dummy_start = GUICtrlCreateDummy() Global $CheckBox1 = GUICtrlCreateCheckbox("Jump", 520, 32, 100, 30, 0) Global $CheckBox2 = GUICtrlCreateCheckbox("Beg", 520, 72, 100, 30, 0) Global $CheckBox3 = GUICtrlCreateCheckbox("Say", 520, 112, 100, 30, 0) Global $CheckBox4 = GUICtrlCreateCheckbox("Roallover", 520, 160, 100, 30, 0) $checkbox_dummy_end = GUICtrlCreateDummy() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Credits MsgBox(64, "Credits", "Matthew Povolotski, Toon:Sniffy Macnose") Case $MyButton1 HotKeySet("{F5}", "_StopIt") $f_Run = True While $f_Run $f_AnyChecked = False If BitAND(GUICtrlRead($CheckBox1), $GUI_CHECKED) Then $f_AnyChecked = True Local $randomcoords[7][2] = [[217,65],[228,79],[173,81],[223,93],[190,110],[214,112],[255,138]] MouseClick("left", 57, 45, 1) MouseClick("left", 127, 61, 1) $r = Random(0,6,1) MouseClick("left", $randomcoords[$r][0], $randomcoords[$r][1], 1) EndIf If BitAND(GUICtrlRead($CheckBox2), $GUI_CHECKED) Then $f_AnyChecked = True Local $randomcoords[7][2] = [[217,75],[228,79],[173,81],[223,93],[190,110],[214,112],[255,138]] MouseClick("left", 57, 45, 1) MouseClick("left", 127, 61, 1) $r = Random(0,6,1) MouseClick("left", $randomcoords[$r][0], $randomcoords[$r][1], 1) EndIf If BitAND(GUICtrlRead($CheckBox3), $GUI_CHECKED) Then $f_AnyChecked = True MsgBox(64, "Checkbox 3", "CheckBox 3 is checked", 1) EndIf If BitAND(GUICtrlRead($CheckBox4), $GUI_CHECKED) Then $f_AnyChecked = True MsgBox(64, "Checkbox 4", "CheckBox 4 is checked", 1) EndIf If Not $f_AnyChecked Then ExitLoop WEnd HotKeySet("{F5}") EndSwitch WEnd Func _StopIt() $f_Run = False EndFunc Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF) ;LoWord Switch $iIDFrom Case $checkbox_dummy_start to $checkbox_dummy_end for $i = $checkbox_dummy_start to $checkbox_dummy_end if $i <> $iIDFrom then GUICtrlSetState($i,4) Next EndSwitch EndFunc  OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Manjish Posted January 28, 2009 Share Posted January 28, 2009 Like this: expandcollapse popup#include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $button_1, $group_1, $radio_1, $radio_2, $radio_3 Local $radio_4, $radio_5, $radio_6, $input_1, $input_2 Local $radioval1, $radioval2, $msg Opt("GUICoordMode", 1) GUICreate("Radio Box Grouping Demo", 400, 280) ; Create the controls $button_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40) $group_1 = GUICtrlCreateGroup("Group 1", 30, 90, 165, 160) GUIStartGroup() $radio_1 = GUICtrlCreateRadio("Radio &0", 50, 120, 70, 20) $radio_2 = GUICtrlCreateRadio("Radio &1", 50, 150, 60, 20) $radio_3 = GUICtrlCreateRadio("Radio &2", 50, 180, 60, 20) ; Set the defaults (radio buttons clicked, default button, etc) GUICtrlSetState($radio_1, $GUI_CHECKED) GUICtrlSetState($radio_6, $GUI_CHECKED) GUICtrlSetState($button_1, $GUI_FOCUS + $GUI_DEFBUTTON) ; Init our vars that we will use to keep track of radio events $radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button $radioval2 = 2 GUISetState() ; In this message loop we use variables to keep track of changes to the radios, another ; way would be to use GUICtrlRead() at the end to read in the state of each control. Both ; methods are equally valid While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button_1 MsgBox(0, "Button", "Radio " & $radioval1) Case $msg = $radio_1 Or $msg = $radio_2 Or $msg = $radio_3 $radioval1 = $msg - $radio_1 Case $msg = $radio_4 Or $msg = $radio_5 Or $msg = $radio_6 $radioval2 = $msg - $radio_4 EndSelect WEnd EndFunc ;==>Example [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
snoopy Posted January 28, 2009 Author Share Posted January 28, 2009 Lova ya m8 , tnx .... btw can you explain what you did? Link to comment Share on other sites More sharing options...
snoopy Posted January 28, 2009 Author Share Posted January 28, 2009 (edited) Lova ya m8 , tnx ....btw can you explain what you did?And i Guess there is no way of getting the buttons go as the pic? Edited January 28, 2009 by snoopy 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