WesW Posted March 31, 2011 Share Posted March 31, 2011 (edited) I am building an Apps options panel using tabs. The 3rd tab will be a list box with 10 different apps listed. Is a list box the best way to go? I already built 10 different software packages, they are working great. I would like to list the apps in the list box and click on the app to have the package run. I have looked at different examples but I was hoping someone can suggest the best way to handle this. I figured out how to list the apps but not how to execute them. Here is the code from tab 3. $tab3 = GUICtrlCreateTabItem("Automated Builds") GUICtrlSetState(-1,$GUI_SHOW) $List1 = GUICtrlCreateList("", 16, 64, 265, 384) $List1 = GUICtrlSetData(-1,"AutoCAD|ProjectWise") GUICtrlSetFont(-1, 8, 400, 0, "Arial") $Group1 = GUICtrlCreateGroup("One Click Installs Packages", 8, 40, 281, 433) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateGroup("", -99, -99, 1, 1) Will it be something like this... GUICTRLREAD ($list1) AutoCAD = Path .... Am I even close Thanks for the help Edited March 31, 2011 by WesW Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 31, 2011 Moderators Share Posted March 31, 2011 WesW, Am I even closePretty close. #include <GuiConstantsEx.au3> $hGui = GUICreate("Test", 250, 250) $hLabel = GUICtrlCreateLabel("Selected item", 10, 180, 230, 20) $hList = GUICtrlCreateList("Item 1", 10, 10, 230, 160) For $i = 2 To 6 GUICtrlSetData($hList, "Item " & $i) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hList GUICtrlSetData($hLabel, GUICtrlRead($hList)) EndSwitch WEnd You would need to use Run or RunWait to execute the selection once you have read it. 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...
Bert Posted March 31, 2011 Share Posted March 31, 2011 PM sent The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
WesW Posted March 31, 2011 Author Share Posted March 31, 2011 (edited) ok, now how do I call out each app. The listed exe opens for all apps. Case $List1 GUICtrlSetData($List1, guictrlread ($list1)) Run("C:\Documents and Settings\walkersw\Desktop\ProjectWise AutoCAD Integration.exe") Getting closer... Case $List1 GUICtrlSetData($List1, guictrlread ($list1))"AutoCAD" Run("C:\Documents and Settings\walkersw\Desktop\ProjectWise AutoCAD Integration.exe") I need a drink:) Edited March 31, 2011 by WesW Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 31, 2011 Moderators Share Posted March 31, 2011 WesW, I would create an array with the name of the app and the path to use to run it. You put the name in the list and then use the path once you have determined the app to run: #include <GuiConstantsEx.au3> #include <Array.au3> Global $aAppList[2][2] = [["AutoCad", "C:\Path\AutoCad.exe"], ["ProjectWise", "C:\Path\ProjectWise.exe"]] $hGui = GUICreate("Test", 250, 250) $hLabel = GUICtrlCreateLabel("Selected item", 10, 180, 230, 20) $hList = GUICtrlCreateList("", 10, 10, 230, 160) For $i = 0 To UBound($aAppList) - 1 GUICtrlSetData($hList, $aAppList[$i][0]) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hList $sItem = GUICtrlRead($hList) $iIndex = _ArraySearch($aAppList, $sItem) MsgBox(0, "Running", $aAppList[$iIndex][1]) EndSwitch WEnd All clear now? 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...
WesW Posted March 31, 2011 Author Share Posted March 31, 2011 (edited) WesW, I would create an array with the name of the app and the path to use to run it. You put the name in the list and then use the path once you have determined the app to run: #include <GuiConstantsEx.au3> #include <Array.au3> Global $aAppList[2][2] = [["AutoCad", "C:\Path\AutoCad.exe"], ["ProjectWise", "C:\Path\ProjectWise.exe"]] $hGui = GUICreate("Test", 250, 250) $hLabel = GUICtrlCreateLabel("Selected item", 10, 180, 230, 20) $hList = GUICtrlCreateList("", 10, 10, 230, 160) For $i = 0 To UBound($aAppList) - 1 GUICtrlSetData($hList, $aAppList[$i][0]) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hList $sItem = GUICtrlRead($hList) $iIndex = _ArraySearch($aAppList, $sItem) MsgBox(0, "Running", $aAppList[$iIndex][1]) EndSwitch WEnd All clear now? M23 ok. i never used an Array before, but that is starting to make since. Where do I set the run command for each app. Run("\\network work path\AutoCAD") Wait would I set the path Global $aAppList[2][2] = [["AutoCad", "\\networkpath\AutoCad.exe"], Edited March 31, 2011 by WesW Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 31, 2011 Moderators Share Posted March 31, 2011 WesW,Yoo would put the Run line where I have put the MsgBox line: Run($aAppList[$iIndex][1])As to what you put in the array - whatever you would use at the command prompt to run the app. 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...
WesW Posted March 31, 2011 Author Share Posted March 31, 2011 Run($aAppList[$iIndex][1]) Sorry M23, thanks for your help but I am not sure... how does the array know what app to install. What part of Run($aAppList[$iIndex][1])tells what app to install. WesW, Yoo would put the Run line where I have put the MsgBox line: Run($aAppList[$iIndex][1]) As to what you put in the array - whatever you would use at the command prompt to run the app. M23 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 31, 2011 Moderators Share Posted March 31, 2011 WesW,Think of a 2-dimensional array as a spreadsheet: $aArray[0][0] $aArray[0][0] $aArray[1][0] $aArray[1][1] $aArray[2][0] $aArray[2][2]You put the name of the app in the first column - this is what you put in the list when you use:GUICtrlSetData($hList, $aAppList[$i][0])When you click in the list to select an item, you read the value and then search for it in the array with:$iIndex = _ArraySearch($aAppList, $sItem)As you can see from the Help file, this will return the index number of the array in which the value was found. You then take the corresponding value from the second dimension of the array to use in the Run command like this:Run($aAppList[$iIndex][1])You need to fill the array at the beginning with the names and paths so that the code can firstly extract the names to fill the list and then extract the corresponding path to run.Does that make sense? There is a good tutorial on Arrays in the Wiki - you might find it useful. M23P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. 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...
WesW Posted March 31, 2011 Author Share Posted March 31, 2011 Thanks for all your help M23. i learned alot! Link to comment Share on other sites More sharing options...
WesW Posted March 31, 2011 Author Share Posted March 31, 2011 ok, one more question. How would I space the text out in the listbox? 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