BlueLord Posted October 8, 2010 Share Posted October 8, 2010 Hy, I need a way to set the number of checked box. Then i can to use this formula to use this formula to set the value of progres: GUICtrlSetData($CtrlProgress2,(($i/NUMBER OF CHECKED CHECBOX"S)*100)) i attached my script with coments. How to handle it? I think is need of second array. I'm not good at array, can somebody help me? second issue: I need a hint how to create a messagebox or better to activate button only when a checkbox is checked, this is to not stat progress if no checkebox is activated and third issue: how to autoclose progress gui after 10sec Thanks, content of dat2.dat [1] 1=1 2=2 3=3 4=4 5=5 6=6 7=7 8=8 9=9Checkbox_Progress.au3 Link to comment Share on other sites More sharing options...
MrMitchell Posted October 9, 2010 Share Posted October 9, 2010 (edited) Added to your $iMsg Switch: While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $test_Button _listCheck() Case $test_Button2 MsgBox(0, "Number of checked boxes", _numberChecked()) Case $Tg_check_[1] _numberChecked() Case $Tg_check_[2] _numberChecked() Case $Tg_check_[3] _numberChecked() Case $Tg_check_[4] _numberChecked() Case $Tg_check_[5] _numberChecked() Case $Tg_check_[6] _numberChecked() Case $Tg_check_[7] _numberChecked() Case $Tg_check_[8] _numberChecked() Case $Tg_check_[9] _numberChecked() EndSwitch WEnd The above will call the _numberChecked function every time you check or uncheck a box. Then here's the _numberChecked() function: Func _numberChecked() Local $count For $each In $tg_check_ If GUICtrlRead($each) = $GUI_CHECKED Then $count += 1 EndIf Next If $count > 0 Then GUICtrlSetState($test_Button2,$GUI_ENABLE) If $count < 1 Then GUICtrlSetState($test_Button2,$GUI_DISABLE) Return $count EndFunc The above function, when called, will run through each checkmark and figure out how many are checked. If more than 0 then enable the button. If less than 1 (0 or less are checked) then disable the button. I also added a case in the Switch to tell you how many check boxes are checked when you click the first button ($test_Button2), but the button will only be clickable when 1 or more check boxes are checked. Hope that makes sense lol... Edit/Add: Probably better to use OnEventMode for the GUI. Now that I look at it there are probably more ways to write what I've done, this is just one of many ways. Also, not sure what you mean about auto-close progress GUI after 10 seconds?? It seems to close on its own after you press ok. Maybe put a 10-second timeout on the Msgbox then the message box will dismiss itself after 10 seconds, then the progress GUI will close after that. Edited October 9, 2010 by MrMitchell Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 23, 2010 Moderators Share Posted October 23, 2010 BlueLord, I hope this helps: expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> ; Read file $sIni = "dat2.dat" $aChecks = IniReadSection($sIni, "1") ; Create GUI $hGUI = GUICreate("Test", 500, 500) ; Create progress $hProgress = GUICtrlCreateProgress(10, 10, 480, 20) ; Create CheckBoxes For $i = 1 To $aChecks[0][0] $aChecks[$i][0] = GUICtrlCreateCheckbox($aChecks[$i][1], 10, ($i * 30) + 20, 100, 20) Next ; Create button $hButton = GUICtrlCreateButton("Go", 10, 460, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton ; Coutn number of checked Checkboxes $iCount = 0 For $i = 1 To $aChecks[0][0] If GUICtrlRead($aChecks[$i][0]) = 1 Then $iCount += 1 Next ; If at least 1 is checked If $iCount > 0 Then ; How much is each checkbox worth? $iSegment = Int(100 / $iCount) ; Now increase the progress by that amount each time Do GUICtrlSetData($hProgress, GUICtrlRead($hProgress) + $iSegment) $iCount -= 1 Sleep(1000) Until $iCount < 0 ; Wait 10 secs Sleep(10000) EndIf ; And exit Exit EndSwitch WEnd But remember what I said - keep it in the open forum in future. 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...
BlueLord Posted October 23, 2010 Author Share Posted October 23, 2010 Hy Melba, You have right!Sorry. I use your idea and i added something in plus after the "While 1" which is continues check the status of the check box's and change the status of $hButton. It's work's but not 100%, the button blink's. is there a way to solve this? expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> ; Read file $sIni = "dat2.dat" $aChecks = IniReadSection($sIni, "1") ; Create GUI $hGUI = GUICreate("Test", 500, 500) ; Create progress $hProgress = GUICtrlCreateProgress(10, 10, 480, 20) ; Create CheckBoxes For $i = 1 To $aChecks[0][0] $aChecks[$i][0] = GUICtrlCreateCheckbox($aChecks[$i][1], 10, ($i * 30) + 20, 100, 20) Next ; Create button $hButton = GUICtrlCreateButton("Go", 10, 460, 80, 30) GUICtrlSetState($hButton,$GUI_DISABLE) ; Here i disable button, initial status is disable GUISetState() While 1 ; I use your ideea and put this "script" wich is continues check the status of the checkbox's and change ;the status of hButton. It's work's but not 100%, the button blink's. $iCount = 0 For $i = 1 To $aChecks[0][0] If GUICtrlRead($aChecks[$i][0]) = 1 Then $iCount += 1 Next If $iCount > 0 Then GUICtrlSetState($hButton,$GUI_ENABLE) If $iCount = 0 Then GUICtrlSetState($hButton,$GUI_DISABLE) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton ; Coutn number of checked Checkboxes ;$iCount = 0 For $i = 1 To $aChecks[0][0] If GUICtrlRead($aChecks[$i][0]) = 1 Then $iCount += 1 Next ; If at least 1 is checked If $iCount > 0 Then ; How much is each checkbox worth? $iSegment = Int(100 / $iCount) ; Now increase the progress by that amount each time Do GUICtrlSetData($hProgress, GUICtrlRead($hProgress) + $iSegment) $iCount -= 1 Sleep(1000) Until $iCount < 0 ; Wait 10 secs Sleep(10000) EndIf ; And exit Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Tvern Posted October 23, 2010 Share Posted October 23, 2010 Replace the lines that change the button state with these: If $iCount > 0 And BitAND(GUICtrlGetState($hButton),$GUI_DISABLE) Then GUICtrlSetState($hButton,$GUI_ENABLE) If $iCount = 0 And BitAND(GUICtrlGetState($hButton),$GUI_ENABLE) Then GUICtrlSetState($hButton,$GUI_DISABLE) The flicker is caused by the state of the button being set over and over, and while there are other ways to reduce the flicker, you should avoid a useless operation like setting a state to the same as it already is. Link to comment Share on other sites More sharing options...
engjcowi Posted October 26, 2010 Share Posted October 26, 2010 Hi Melba23 i wanted to thank you so much for the code that you supplied above that ive listed below. I spent hours trying to figure that out and then just happened to come accross it lol Thanks again $iSegment = Int(100 / $iCount) ; Now increase the progress by that amount each time Do GUICtrlSetData($hProgress, GUICtrlRead($hProgress) + $iSegment) Drunken Frat-Boy Monkey Garbage 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