autoitquestion Posted April 22, 2011 Share Posted April 22, 2011 Hi, I tried create more than one check box in same UI , however, in same time, I see only one This what I did: Local $avArray[3]=["Hanna","Danny","Moshe"] Local $checkCN, $msg, $start, $i GUICreate("Check boxes") ; will create a dialog box that when displayed is centered $start=20 For $i = 1 to 3 Step 1 GUICtrlCreateCheckbox($avArray[$i], 10, 10, 120, $start) $start +=30 Next GUISetState() Let me know where I'm mistake.. Thanks in advance! Noa :-) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 22, 2011 Moderators Share Posted April 22, 2011 autoitquestion,- 1. Your array runs from 0 to 2, not 1 to 3 - and you do not need Step 1, that is the default.- 2. You were increasing the "height" parameter - you need to change the "top":Local $avArray[3]=["Hanna","Danny","Moshe"] Local $checkCN, $msg, $start, $i GUICreate("Check boxes") ; will create a dialog box that when displayed is centered $start=20 For $i = 0 to 2 ; Step 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlCreateCheckbox($avArray[$i], 10, $start, 120, 20) ; <<<<<<<<<<<<<<< $start +=30 Next GUISetState() While 1 If GUIGetMsg() = -3 Then Exit WEndLook for the <<<<<<<<<<<<< lines. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
autoitquestion Posted April 22, 2011 Author Share Posted April 22, 2011 Oh... It's working!! thanks a lot.. After, I also create button: $btn = GUICtrlCreateButton("Run", 120, 200, 60, 20) And then I wish to get user selections.. Where I have user selections? Hope my question is clear... Thanks a lot!! Noa :-) Link to comment Share on other sites More sharing options...
autoitquestion Posted April 22, 2011 Author Share Posted April 22, 2011 Oh... It's working!! thanks a lot.. After, I also create button: $btn = GUICtrlCreateButton("Run", 120, 200, 60, 20) And then I wish to get user selections.. Where I have user selections? Hope my question is clear... Thanks a lot!! Noa :-) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 22, 2011 Moderators Share Posted April 22, 2011 (edited) autoitquestion, You need to look at the state of the checkboxes like this: #include <GUIConstantsEx.au3> Global $avArray[3] = ["Hanna", "Danny", "Moshe"] Global $avCheckID[3] Global $checkCN, $msg, $start, $i GUICreate("Check boxes") ; will create a dialog box that when displayed is centered $start = 20 For $i = 0 To 2 $avCheckID[$i] = GUICtrlCreateCheckbox($avArray[$i], 10, $start, 120, 20) $start += 30 Next $btn = GUICtrlCreateButton("Run", 120, 200, 60, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $btn ; Loop through the checkboxes For $i = 0 To 2 ; Is this one checked? If GUICtrlRead($avCheckID[$i]) = 1 Then ; If so then say so ConsoleWrite("Checkbox " & $avArray[$i] & " is checked" & @CRLF) EndIf ConsoleWrite(@CRLF) Next EndSwitch WEnd All clear? M23 Edit: Added the missing ; Edited April 22, 2011 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
autoitquestion Posted April 22, 2011 Author Share Posted April 22, 2011 Thanks a lot for all your help! very appricate it.. I dont know why, but it's did not work 4 me well. It wrote to console different selection from what I selected... Link to comment Share on other sites More sharing options...
autoitquestion Posted April 22, 2011 Author Share Posted April 22, 2011 It did not return strings values of the array.. Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 22, 2011 Share Posted April 22, 2011 Really? Other than a missing semicolon on a comment: ; Is this one checked? Melba's demo runs perfectly for me and calls out the correct selections. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
autoitquestion Posted April 22, 2011 Author Share Posted April 22, 2011 Yes, this is clear.. but I still did not found my problem.. I'll check it again and will update Link to comment Share on other sites More sharing options...
autoitquestion Posted April 22, 2011 Author Share Posted April 22, 2011 Okay.. it's working.. my mistake.. Just wish to know how can I select check box from my script? Cause I wish to make check box that will select all options Thanks a lot for all your help! Very appreciate your help.. Link to comment Share on other sites More sharing options...
autoitquestion Posted April 22, 2011 Author Share Posted April 22, 2011 all it's okay for now.. thanks you all! Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 22, 2011 Share Posted April 22, 2011 Melba's demo, plus "Select All" and "Clear All" buttons: expandcollapse popup#include <GUIConstantsEx.au3> Global $avArray[3] = ["Hanna", "Danny", "Moshe"] Global $hGUI, $avCheckID[3] Global $checkCN, $msg, $start, $i $hGUI = GUICreate("Check boxes") ; will create a dialog box that when displayed is centered $start = 20 For $i = 0 To 2 $avCheckID[$i] = GUICtrlCreateCheckbox($avArray[$i], 10, $start, 120, 20) $start += 30 Next $btn = GUICtrlCreateButton("Run", 120, 200, 60, 20) $btnSel = GUICtrlCreateButton("Sel All", 120, 240, 60, 20) $btnClr = GUICtrlCreateButton("Clr All", 120, 280, 60, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $btn ; Loop through the checkboxes For $i = 0 To 2 ; Is this one checked? If GUICtrlRead($avCheckID[$i]) = 1 Then ; If so then say so ConsoleWrite("Checkbox " & $avArray[$i] & " is checked" & @CRLF) EndIf ConsoleWrite(@CRLF) Next Case $btnSel _ChangeAll(1) Case $btnClr _ChangeAll(0) EndSwitch WEnd Func _ChangeAll($f_State) For $n = 0 To UBound($avCheckID) - 1 If $f_State Then ControlCommand($hGUI, "", $avCheckID[$n], "Check") Else ControlCommand($hGUI, "", $avCheckID[$n], "Uncheck") EndIf Next EndFunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
autoitquestion Posted April 23, 2011 Author Share Posted April 23, 2011 (edited) Thanks a lot!! I wish to do clear all and select all buttons with check box Assume: $SelAll=GUICtrlCreateCheckbox($string,200, 10, 120, 20) So my questions is: How can I change text of check box suitable to check box status (if V select all and if V removed so text will be remove all)-I tried define global variable $string="Select all" and add case like this: Case GUICtrlRead($SelAll) = 1 $string="Select all" Case GUICtrlRead($SelAll) = 4 $string="Remove all" but it's doesn't work-question is why.. Thanks a lot!!! Noa :-) Edited April 23, 2011 by autoitquestion Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 23, 2011 Moderators Share Posted April 23, 2011 autoitquestion,Her is how you can do it with checkbox: expandcollapse popup#include <GUIConstantsEx.au3> Global $avArray[3] = ["Hanna", "Danny", "Moshe"] Global $hGUI, $avCheckID[3] Global $checkCN, $msg, $start, $i $hGUI = GUICreate("Check boxes") ; will create a dialog box that when displayed is centered $start = 20 For $i = 0 To 2 $avCheckID[$i] = GUICtrlCreateCheckbox($avArray[$i], 10, $start, 120, 20) $start += 30 Next $btn = GUICtrlCreateButton("Run", 120, 200, 60, 20) $chkSel = GUICtrlCreateCheckbox("Sel All", 120, 240, 60, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $btn ; Loop through the checkboxes For $i = 0 To 2 ; Is this one checked? If GUICtrlRead($avCheckID[$i]) = 1 Then ; If so then say so ConsoleWrite("Checkbox " & $avArray[$i] & " is checked" & @CRLF) EndIf ConsoleWrite(@CRLF) Next Case $chkSel Switch GUICtrlRead($chkSel) Case 1 For $i = 0 To 2 GUICtrlSetState($avCheckID[$i], $GUI_CHECKED) Next Case Else For $i = 0 To 2 GUICtrlSetState($avCheckID[$i], $GUI_UNCHECKED) Next EndSwitch EndSwitch WEndM23P.S. When you post code please use Code tags. Put [autoit] before and [/autoit] after your posted code. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
autoitquestion Posted April 23, 2011 Author Share Posted April 23, 2011 Thanks a lot Melba!! And how can I change text of check box suitable to check box status (if V select all and if V removed so text will be remove all)? I tried define global variable and change it in the suitable case, but did not know why it's did not work expandcollapse popup#include <GUIConstantsEx.au3> Global $avArray[3] = ["Hanna", "Danny", "Moshe"] Global $hGUI, $avCheckID[3] Global $checkCN, $msg, $start, $i Local $string="Select all" $hGUI = GUICreate("Check boxes") ; will create a dialog box that when displayed is centered $start = 20 For $i = 0 To 2 $avCheckID[$i] = GUICtrlCreateCheckbox($avArray[$i], 10, $start, 120, 20) $start += 30 Next $btn = GUICtrlCreateButton("Run", 120, 200, 60, 20) $chkSel = GUICtrlCreateCheckbox($string, 120, 240, 60, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $btn ; Loop through the checkboxes For $i = 0 To 2 ; Is this one checked? If GUICtrlRead($avCheckID[$i]) = 1 Then ; If so then say so ConsoleWrite("Checkbox " & $avArray[$i] & " is checked" & @CRLF) EndIf ConsoleWrite(@CRLF) Next Case $chkSel Switch GUICtrlRead($chkSel) Case 1 For $i = 0 To 2 GUICtrlSetState($avCheckID[$i], $GUI_CHECKED) Next $string="Remove all" Case Else For $i = 0 To 2 GUICtrlSetState($avCheckID[$i], $GUI_UNCHECKED) Next $string="Select all" EndSwitch EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 23, 2011 Moderators Share Posted April 23, 2011 autoitquestion, Just change the checkbox text to match the state: Case $chkSel Switch GUICtrlRead($chkSel) Case 1 For $i = 0 To 2 GUICtrlSetState($avCheckID[$i], $GUI_CHECKED) Next GUICtrlSetData($chkSel, "Remove All") Case Else For $i = 0 To 2 GUICtrlSetState($avCheckID[$i], $GUI_UNCHECKED) Next GUICtrlSetData($chkSel, "Sel All") EndSwitch But personally I feel that this is not a good idea - it is the state of the checkbox that tells you what the next action should be. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
autoitquestion Posted April 23, 2011 Author Share Posted April 23, 2011 Thanks a lot Melba!! you're the best 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