Jump to content

ListBox Question


WesW
 Share

Recommended Posts

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 by WesW
Link to comment
Share on other sites

  • Moderators

WesW,

Am I even close

Pretty 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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 by WesW
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 by WesW
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

  • Moderators

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. :)

M23

P.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. :P

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...