Jewtus Posted October 27, 2016 Posted October 27, 2016 I'm attempting to perform a loop to create a sub menu for each drive on a machine and then I want to call a function using the selected drive name. This is an example of my menu: $mBuild = GUICtrlCreateMenu("Create Share folder") $aDrivesList = DriveGetDrive('ALL') _ArrayColInsert($aDrivesList, 1) For $x = 1 To UBound($aDrivesList) - 1 $aDrivesList[$x][1]=GUICtrlCreateMenuItem(StringUpper($aDrivesList[$x][0] & "\"), $mBuild) Next When I do my case statement in the gui... how do I make the case trigger based off which one was selected? If I can figure out the index of the one selected, I can use the array to pull back the text. This is the case statement for my UI: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $mExit GUIDelete($MachineSelectorGUI) ExitLoop Case $mBuild BuildShare() EndSwitch WEnd
LarsJ Posted October 28, 2016 Posted October 28, 2016 ; Assuming that $aDrivesList is already filled with menu items ; the Case statement should look something like this: Case $aDrivesList[1][1] To $aDrivesList[UBound($aDrivesList)-1][1] $x = $nMsg - $aDrivesList[1][1] + 1 ; $x is index in $aDrivesList Jewtus 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
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