Sign in to follow this  
Followers 0
fcr0w

TreeViewListitem

5 posts in this topic

Hello all, I need to know how to select an item from a treelistview and run a command from that selected item.

Thanks :">

Share this post


Link to post
Share on other sites



Sorry about not having code to work with well this what I have done so far:

We have OS images already setup what I need to know is to code some commands that will execute a single image from the choosen list coded below

Thanks for the input

#include <GUIConstantsEx.au3>

#include <GuiTreeView.au3>

#include <GuiStatusBar.au3>

#include <GUIConstants.au3>

GUICreate("Product Testing Lab - Main Menu", 470, 500)

$ProdTestLab = GUICtrlCreateTreeView(10, 10, 300, 400, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)

$LabImageMenu = GUICtrlCreateTreeViewitem ("LAB IMAGE MENU",$ProdTestLab)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",9)

$EngImg = GUICtrlCreateTreeViewitem ("English",$LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$EngImgW2KPRO=GUICtrlCreateTreeViewitem ("Windows 2000 Professional",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgW2KSRV=GUICtrlCreateTreeViewitem ("Windows 2000 Server",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgW2KADV=GUICtrlCreateTreeViewitem ("Windows 2000 Advanced Server",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgWXPPRO=GUICtrlCreateTreeViewitem ("Windows XP Professional",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgW3KWEB=GUICtrlCreateTreeViewitem ("Windows 2003 Web Server",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgW3KSTA=GUICtrlCreateTreeViewitem ("Windows 2003 Standard Server",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgW3KENT=GUICtrlCreateTreeViewitem ("Windows 2003 Enterprise Server",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgVDRTCI=GUICtrlCreateTreeViewitem ("2000 Server Development VDRTCI",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$chsImgs = GUICtrlCreateTreeViewitem ("Chinese Simplified Images",$LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$chtImgs = GUICtrlCreateTreeViewitem ("Chinese Traditional Images",$LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$freImgs = GUICtrlCreateTreeViewItem("French Images", $LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$gerImgs = GUICtrlCreateTreeViewItem("German Images", $LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$japImgs = GUICtrlCreateTreeViewItem("Japanese Images", $LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$korImgs = GUICtrlCreateTreeViewItem("Korean Images", $LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$AdminMenu = GUICtrlCreateTreeViewitem ("ADMINS LAB MENU",$ProdTestLab)

GUISetState()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

Share this post


Link to post
Share on other sites

Simply add

$msg = Var

Like this

#include <GUIConstantsEx.au3>

#include <GuiTreeView.au3>

#include <GuiStatusBar.au3>

#include <GUIConstants.au3>

GUICreate("Product Testing Lab - Main Menu", 470, 500)

$ProdTestLab = GUICtrlCreateTreeView(10, 10, 300, 400, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)

$LabImageMenu = GUICtrlCreateTreeViewitem ("LAB IMAGE MENU",$ProdTestLab)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",9)

$EngImg = GUICtrlCreateTreeViewitem ("English",$LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$EngImgW2KPRO=GUICtrlCreateTreeViewitem ("Windows 2000 Professional",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgW2KSRV=GUICtrlCreateTreeViewitem ("Windows 2000 Server",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgW2KADV=GUICtrlCreateTreeViewitem ("Windows 2000 Advanced Server",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgWXPPRO=GUICtrlCreateTreeViewitem ("Windows XP Professional",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgW3KWEB=GUICtrlCreateTreeViewitem ("Windows 2003 Web Server",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgW3KSTA=GUICtrlCreateTreeViewitem ("Windows 2003 Standard Server",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgW3KENT=GUICtrlCreateTreeViewitem ("Windows 2003 Enterprise Server",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$EngImgVDRTCI=GUICtrlCreateTreeViewitem ("2000 Server Development VDRTCI",$EngImg)

GUICtrlSetImage (-1, "shell32.dll",2)

$chsImgs = GUICtrlCreateTreeViewitem ("Chinese Simplified Images",$LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$chtImgs = GUICtrlCreateTreeViewitem ("Chinese Traditional Images",$LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$freImgs = GUICtrlCreateTreeViewItem("French Images", $LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$gerImgs = GUICtrlCreateTreeViewItem("German Images", $LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$japImgs = GUICtrlCreateTreeViewItem("Japanese Images", $LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$korImgs = GUICtrlCreateTreeViewItem("Korean Images", $LabImageMenu)

GUICtrlSetColor(-1, 0x0000C0)

GUICtrlSetImage (-1, "shell32.dll",4)

$AdminMenu = GUICtrlCreateTreeViewitem ("ADMINS LAB MENU",$ProdTestLab)

GUISetState()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

If $msg = $EngImgVDRTCI Then MsgBox(0,0,"Anything")

Wend


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>
#include <GUIConstants.au3>

Global Const $WM_NOTIFY = 0x004E
Global Const $NM_FIRST = 0
Global Const $NM_CLICK = ($NM_FIRST - 2)
Global Const $NM_DBLCLK = ($NM_FIRST - 3)

GUICreate("Product Testing Lab - Main Menu", 470, 500)
$ProdTestLab = GUICtrlCreateTreeView(10, 10, 300, 400, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$LabImageMenu = GUICtrlCreateTreeViewItem("LAB IMAGE MENU", $ProdTestLab)
GUICtrlSetColor(-1, 0x0000C0)
GUICtrlSetImage(-1, "shell32.dll", 9)
$EngImg = GUICtrlCreateTreeViewItem("English", $LabImageMenu)
GUICtrlSetColor(-1, 0x0000C0)
GUICtrlSetImage(-1, "shell32.dll", 4)
$EngImgW2KPRO = GUICtrlCreateTreeViewItem("Windows 2000 Professional", $EngImg)
GUICtrlSetImage(-1, "shell32.dll", 2)
$EngImgW2KSRV = GUICtrlCreateTreeViewItem("Windows 2000 Server", $EngImg)
GUICtrlSetImage(-1, "shell32.dll", 2)
$EngImgW2KADV = GUICtrlCreateTreeViewItem("Windows 2000 Advanced Server", $EngImg)
GUICtrlSetImage(-1, "shell32.dll", 2)
$EngImgWXPPRO = GUICtrlCreateTreeViewItem("Windows XP Professional", $EngImg)
GUICtrlSetImage(-1, "shell32.dll", 2)
$EngImgW3KWEB = GUICtrlCreateTreeViewItem("Windows 2003 Web Server", $EngImg)
GUICtrlSetImage(-1, "shell32.dll", 2)
$EngImgW3KSTA = GUICtrlCreateTreeViewItem("Windows 2003 Standard Server", $EngImg)
GUICtrlSetImage(-1, "shell32.dll", 2)
$EngImgW3KENT = GUICtrlCreateTreeViewItem("Windows 2003 Enterprise Server", $EngImg)
GUICtrlSetImage(-1, "shell32.dll", 2)
$EngImgVDRTCI = GUICtrlCreateTreeViewItem("2000 Server Development VDRTCI", $EngImg)
GUICtrlSetImage(-1, "shell32.dll", 2)
$chsImgs = GUICtrlCreateTreeViewItem("Chinese Simplified Images", $LabImageMenu)
GUICtrlSetColor(-1, 0x0000C0)
GUICtrlSetImage(-1, "shell32.dll", 4)
$chtImgs = GUICtrlCreateTreeViewItem("Chinese Traditional Images", $LabImageMenu)
GUICtrlSetColor(-1, 0x0000C0)
GUICtrlSetImage(-1, "shell32.dll", 4)
$freImgs = GUICtrlCreateTreeViewItem("French Images", $LabImageMenu)
GUICtrlSetColor(-1, 0x0000C0)
GUICtrlSetImage(-1, "shell32.dll", 4)
$gerImgs = GUICtrlCreateTreeViewItem("German Images", $LabImageMenu)
GUICtrlSetColor(-1, 0x0000C0)
GUICtrlSetImage(-1, "shell32.dll", 4)
$japImgs = GUICtrlCreateTreeViewItem("Japanese Images", $LabImageMenu)
GUICtrlSetColor(-1, 0x0000C0)
GUICtrlSetImage(-1, "shell32.dll", 4)
$korImgs = GUICtrlCreateTreeViewItem("Korean Images", $LabImageMenu)
GUICtrlSetColor(-1, 0x0000C0)
GUICtrlSetImage(-1, "shell32.dll", 4)
$AdminMenu = GUICtrlCreateTreeViewItem("ADMINS LAB MENU", $ProdTestLab)
GUISetState()

GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

;~  If $msg = $EngImgVDRTCI Then
;~      $item = GUICtrlRead($ProdTestLab )      ; Get the controlID of the current selected treeview item
;~      If $item = 0 Then
;~          MsgBox(64, "TreeView Demo", "No item currently selected")
;~      Else
;~          $text = GUICtrlRead($item, 1) ; Get the text of the treeview item
;~          If $text == "" Then
;~              MsgBox(16, "Error", "Error while retrieving infos about item")
;~          Else
;~              MsgBox(64, "TreeView Demo", "Current item selected is: " & $text)  ; $advmsg[0] contains the text and $advmsg[1] the state value of the treeview item
;~          EndIf
;~      EndIf
;~  EndIf
WEnd

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event
    
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    
    Select
        Case $wParam = $ProdTestLab ; treeview
            Select
                Case $event = $NM_DBLCLK
                    $h_item = GUICtrlSendMsg($ProdTestLab , $TVM_GETNEXTITEM, $TVGN_CARET, 0)
                    If $h_item > 0 Then
                        $szPath = _GUICtrlTreeViewGetText($ProdTestLab, $h_item)
;~                      If FileExists($szPath) Then Run($szPath)
                        MsgBox(0,'Selection',$szPath)
                    EndIf
            EndSelect
    EndSelect
EndFunc

Share this post


Link to post
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
Sign in to follow this  
Followers 0