Mau75 Posted January 7, 2011 Share Posted January 7, 2011 Hi, Can anybody help? I need to create a function that will execute the moment I select an item in a combobox The items in this combobox is dynamic and get populated with another function. Then as soon as a selection is been made from this ComboBox, it needs to call another function and execute. Alternatively I will need to create some "extra" buttons to do the job... Thanx in advance. Regards, Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 7, 2011 Moderators Share Posted January 7, 2011 Mau75, execute the moment I select an itemFast enough? #include <GUIConstantsEx.au3> #include <GUIComboBox.au3> $hGUI = GUICreate("Test", 500, 500) $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData($hCombo, "One|Two|Three|Four|Five") GUISetState() $sCurrCombo = "" While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; If combo is closed and selection has changed If GUICtrlRead($hCombo) <> $sCurrCombo And _GUICtrlComboBox_GetDroppedState($hCombo) = False Then $sText = GUICtrlRead($hCombo) $sCurrCombo = $sText _Function($sText) EndIf ; If combo opened reset flag to allow for selection of same item If _GUICtrlComboBox_GetDroppedState($hCombo) Then $sCurrCombo = "" WEnd Func _Function($sText) MsgBox(0, "Selection", $sText) EndFunc If not we can look into intercepting the EN_CHANGE message from the combo's edit control. 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...
Mau75 Posted January 7, 2011 Author Share Posted January 7, 2011 Yip, it's fast... I will however only look at it over the weekend. My eyes is busy looking over each other and need to get some sleep... Currently 00h30 Thanx, Link to comment Share on other sites More sharing options...
Mau75 Posted January 8, 2011 Author Share Posted January 8, 2011 (edited) Hi Melba23, Thanx for the code, It's working the way I intented it should be. Now only one BIG problem (for me any case). Where and how do I implement it in my code? Here is short peaces explaining my current setup and controls where it shoul be...: expandcollapse popup#RequireAdmin #include <GUIConstantsEx.au3> #Include <String.au3> #include <EditConstants.au3> #include <GuiEdit.au3> #include <ComboConstants.au3> #include <WindowsConstants.au3> #include "diskpart.au3" Opt("GUIOnEventMode", 1) $hGUI = GUICreate("WinFE - Diskpart Interface", 500, 500) $ListDButton = GUICtrlCreateButton("List Disk", 10, 50, 120, 25) ;Create the button $hLabelDisk = GUICtrlCreateLabel("Select Target Disk: ", 10, 90, 135, 40) ;Create label for disks $mComboDisk = GUICtrlCreateCombo("", 125, 85,40) ; create Combo box for Disks selection GUICtrlSetState($mComboDisk,$GUI_DISABLE) ;disable the disk combobox until list disk is run $hEdit = GUICtrlCreateEdit("Feedback from the DISKPART commands being executed", 10, 120, 480, 370, BitOR($ES_MULTILINE,$ES_READONLY)) ; Create an edit control GUICtrlSetFont ($hEdit, 8, 400, 0,"Lucida Console") ;Use of fixed size fonts for alignment purposes GUICtrlSetOnEvent($ListDButton, "ButtonDFunction") ; The button's function GUISetState(@SW_SHOW) ;Show the GUI. While 1 Sleep(10); So we don't use heaps of CPU WEnd Func ButtonDFunction() ;==>List Disk ButtonFunction GUICtrlSetData($mComboDisk, "", "") GUICtrlSetData($hEdit, "", "") _DiskpartStartConsole( $pid, $version, $runError ) ;Call function in diskpart.au3 to start the diskpart.exe console GUICtrlSetData($hEdit, "Interacting with Microsoft Diskpart version " & $version & @CRLF & @CRLF) _WriteDiskCtrlEdit() EndFunc ;==>ButtonFunction End Func _WriteDiskCtrlEdit() ;==> Write List Disk info to the Edit box $diskCount = _DiskpartListDisks( $pid, $myDisks, $myDisksNum) ;; Start list disk and create combo box list - diskpart.au3 $DLIST = "" For $n=0 To $myDisksNum $DLIST = $DLIST & $myDisks[$n][0] & "|" Next GUICtrlSetState($mComboDisk,$GUI_ENABLE) GUICtrlSetData($mComboDisk, $DLIST, "") Local $text = "" $read = GUICtrlRead($hEdit) $text = $read & StringFormat( "%-8s %-8s %-10s %-10s Dyn Gpt", "Disk ###", "Status", "Size", "Free" ) & @CRLF & _ "-------- -------- ---------- ---------- --- ---" & @CRLF ; Join the existing and the new text seperated by a line. GUICtrlSetData($hEdit, $text) For $m=0 To $myDisksNum $read3 = GUICtrlRead($hEdit) $text = $read3 & StringFormat( "%-8s %-8s %10s %10s %-3s %-3s", _ "Disk " & $myDisks[$m][0], $myDisks[$m][1], $myDisks[$m][2], _ $myDisks[$m][3], $myDisks[$m][4], $myDisks[$m][5]) & @CRLF GUICtrlSetData($hEdit, $text) Next GUICtrlSetState($ListVButton,$GUI_SHOW) EndFunc ;==>WriteEditCtrl End So basically after the _WriteDiskCtrlEdit() it will populate the $mComboDisk = GUICtrlCreateCombo combobox. Then once this is enabled and populated, should your code kick in. This will call another function in the diskpart.au3 basically selecting the disk that's been selected, and list the volumes on that disk. This in turn will enable and populate another combobox (sameway the first is done) and another selection will be made (with no event). Once the volume and disks is selected the "Bring online" button will be enabled and executed. One again another function will be called from the diskpart.au3. Hope this make sense of what I need to do... So do I need to add your code in the while loop, or can I create something simular to "GUICtrlSetOnEvent($ListDButton, "ButtonDFunction")"? Thanx for you assistance thus far. Regards, Edited January 8, 2011 by Mau75 Link to comment Share on other sites More sharing options...
JohnOne Posted January 8, 2011 Share Posted January 8, 2011 You did not mention that you were using oneventmode or I'm sure M23s answer would have been different. Sure you can use setonevent, which will have the same affect more or less. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 8, 2011 Moderators Share Posted January 8, 2011 Mau75, Replace your function with this version which waits until you have selected a value in the combo before returning: Func ButtonDFunction() ;==>List Disk ButtonFunction GUICtrlSetData($mComboDisk, "", "") GUICtrlSetData($hEdit, "", "") _DiskpartStartConsole( $pid, $version, $runError ) ;Call function in diskpart.au3 to start the diskpart.exe console GUICtrlSetData($hEdit, "Interacting with Microsoft Diskpart version " & $version & @CRLF & @CRLF) _WriteDiskCtrlEdit() ; Wait until combo is closed and selection has been made Do Sleep(10) Until GUICtrlRead($mComboDisk) <> "" And _GUICtrlComboBox_GetDroppedState($mComboDisk) = False ; You get here when a selection has been made in the combo ; So now do the next thing you need EndFunc ;==>ButtonFunction End Does that fit in with the rest of your code? 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...
Mau75 Posted January 8, 2011 Author Share Posted January 8, 2011 Does that fit in with the rest of your code? M23I think so... Thanx, it's working greate.There is only one other thing that I need. The commands when executed (especially the initial List Disk, take some time to complete, due to the amount of disks installed on the system and whether the disk already went into idle mode.I need some sort of indication that the program is "busy". Currently it looks like the program just hangs and do nothing. Some sort of popup that will close as soon as the function return from diskpart.au3.MB Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 8, 2011 Moderators Share Posted January 8, 2011 Mau75, Sounds like what the marquee progress was designed for: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ProgressConstants.au3> Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Test", 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_On_Exit") $hProgress = GUICtrlCreateProgress(10, 10, 400, 20, $PBS_MARQUEE) GUICtrlSendMsg(-1, $PBM_SETMARQUEE, True, 50) ; final parameter is update time in ms GUICtrlCreateButton("Stop", 10, 400, 80, 30) GUICtrlSetOnEvent(-1, "_On_Button") GUISetState() While 1 Sleep(10) WEnd Func _On_Button() GUICtrlSetStyle($hProgress, $GUI_SS_DEFAULT_PROGRESS) EndFunc Func _On_Exit() Exit EndFunc The button shows how best to stop it - unless you want to delete the whole thing of course! 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...
Mau75 Posted January 8, 2011 Author Share Posted January 8, 2011 Thanx for the info. It looks great and will use it. I will mention you for your assistance... Now back to sorting out that diskpart.au3 before I can go on... Most of the stuff only work on earlier versions of diskpart and in some cases in Spanish. Then also MS that stick with standards... I need it to work in Win7 & WinPE3 Speak later. 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