Spongioblast Posted March 26, 2017 Share Posted March 26, 2017 Hi guys I am trying to figure out how to loop through all the gui buttons and check if the button contains any description. (The buttons description is read from a function which gets the description from the ini file). If the button has no description, it should be hidden. Now my issue is, how do I get all the buttons of the created UI into an array, so I can loop through them? Cheers Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 26, 2017 Moderators Share Posted March 26, 2017 Spongioblast, Just place the buttons into an array when creating them - I show how you might do it in this post. 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...
kylomas Posted March 27, 2017 Share Posted March 27, 2017 Spongioblast, If you want to get existing controls try something like this... expandcollapse popup#include <array.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPISys.au3> ;-------------------------------------------------------------------------------------- ; Create A gui with controls ;-------------------------------------------------------------------------------------- Local $gui010 = GUICreate('Class Dump') For $1 = 1 To 10 GUICtrlCreateButton('B' & $1, $1 * 30, 20, 25, 20) GUICtrlCreateInput('I' & $1, $1 * 30, 45, 25, 20) GUICtrlCreateLabel('S' & $1, $1 * 30, 70, 25, 20, $SS_SUNKEN) Next Local $btn010 = GUICtrlCreateButton('Show Array of Controls', 10, 350, 200, 20) GUISetState() ;-------------------------------------------------------------------------------------- ; Enumerate child windows (controls) with CTLID and TEXT ;-------------------------------------------------------------------------------------- While 1 $msg = GUIGetMsg() Switch $msg Case $gui_event_close Exit Case $btn010 _Show() EndSwitch WEnd Func _Show() Local $aWin = _WinAPI_EnumChildWindows($gui010) _ArrayDelete($aWin, 0) Local $aFinal[UBound($aWin)][4] For $1 = 0 To UBound($aWin) - 1 $aFinal[$1][0] = $aWin[$1][0] $aFinal[$1][1] = $aWin[$1][1] $aFinal[$1][2] = _WinAPI_GetWindowLong($aFinal[$1][0], $GWL_ID) $aFinal[$1][3] = ControlGetText('', '', $aFinal[$1][2]) Next _ArrayDisplay($aFinal, 'Active Window Control Enumeration', '', 0, Default, 'HWND|CLASS|CTLID|TEXT') EndFunc ;==>_Show kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
spudw2k Posted March 31, 2017 Share Posted March 31, 2017 Good solutions from @Melba23 and @kylomas. Melba's is good for real-time and programmatic creation of the controls; Kylomas' is good for enumerating controls. I have one to offer as well which works best (for me) for "static" controls. I tend to use this method for most "complex" GUIs I make. Basically I create an array and ENUM constants at the beginning of the script that house all my GUI controls, then assign the array indexes to the controls when I create them. For example (snippet from my SubNet Calc script in signature): I start by creating an array with 1 element, set to "hwnd|id" Then I create constants using ENUM for the GUI ID/handle itself, each GUI control and a LAST const I Resize/ReDim the array increase the size to the hwnd/ID count (LAST const simplifies this) Global $aGUI[1] = ["hwnd|id"] Global Enum $hGUI = 1, $idDummyEnter, $idIPHost, $idIPSubnetMask, $idIPStart, $idIPEnd, $idIPNet, $idIPBroadcast, $idSubnetBits, $idHostCount, $iGUILast ReDim $aGUI[$iGUILast] Then I assign each control to the appropriate Array Index (using the Constants I created for easy reference. $aGUI[$hGUI] = GUICreate("IP Subnet Calc", 258, 330) $aGUI[$idDummyEnter] = GUICtrlCreateDummy() $aGUI[$idIPHost] = _GUICtrlIpAddress_Create($aGUI[$hGUI], 70, 33, 130, 18) $aGUI[$idSubnetBits] = GUICtrlCreateInput("0", 212, 33, 24, 18, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) $aGUI[$idIPSubnetMask] = _GUICtrlIpAddress_Create($aGUI[$hGUI], 70, 65, 130, 18) $aGUI[$idIPStart] = _GUICtrlIpAddress_Create($aGUI[$hGUI], 90, 133, 130, 18, $WS_DISABLED) $aGUI[$idIPEnd] = _GUICtrlIpAddress_Create($aGUI[$hGUI], 90, 165, 130, 18, $WS_DISABLED) ;etc... Hopefully this makes sense. I like doing this as it makes it very easy for me to access my controls from a variable (human readable). It may not suit your needs, but I figured I'd share yet another method. Here are a couple more scripts of mine (in my signature) that use this "convention" in case you want more examples: AU History Plasma_kIt VMWare ESX Builder ss26 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF 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