Jump to content

Get parent item and feed variable


weevil
 Share

Recommended Posts

Hey,

 

My brain is completely frazzled and I'm unable to workout how to do what I need here. 

So I have a multi-level tree view for the user to select which is working fine.  It's for users to select what system to connect to.  The multi levelled tree view mirrors a folder/file structure that has the files for auto it to load according to what the user selects for example.

 

User clicks on server 1 which is inside folder a which is inside folder b.  That will load the file x:\\folder b\folder a\server 1.file make sense?

 

The question is how can we translate the root of each brand to correspond to folders ?  My code is this:

 

#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiTreeView.au3>
#include <GuiListView.au3>
global $text = ""
global $dir = "path\to\software"
GUI()
sleep(1000)
load()
Func GUI()
    Local $hGUI = GUICreate("Select System", 314, 314)
    Local $idTreeView_1 = GUICtrlCreateTreeView(6, 6, 300, 260, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT), $WS_EX_CLIENTEDGE)
    Local $hTreeView_1 = ControlGetHandle($hGUI, "", $idTreeView_1)
    Local $button1 = GUICtrlCreateButton("Select", 127, 270, 60, 30)                            ;button size
    Local $idRoot1 = GUICtrlCreateTreeViewItem("servertype3", $idTreeView_1)
      Local $idRoot1Item1 = GUICtrlCreateTreeViewItem("folderb", $idRoot1)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
      Local $idRoot1Item2 = GUICtrlCreateTreeViewItem("foldera", $idRoot1)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
    Local $idRoot2 = GUICtrlCreateTreeViewItem("servertype3", $idTreeView_1)
      Local $idRoot1Item3 = GUICtrlCreateTreeViewItem("folder1", $idRoot2)
         GUICtrlCreateTreeViewItem("x xx-x", $idRoot1Item3)
         GUICtrlCreateTreeViewItem("x x x", $idRoot1Item3)
         GUICtrlCreateTreeViewItem("x x", $idRoot1Item3)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item3)
         GUICtrlCreateTreeViewItem("xx xx", $idRoot1Item3)
         GUICtrlCreateTreeViewItem("x x", $idRoot1Item3)
      Local $idRoot1Item4 = GUICtrlCreateTreeViewItem("folder2", $idRoot2)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
         GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
    Local $idRoot3 = GUICtrlCreateTreeViewItem("servertype1", $idTreeView_1)
         GUICtrlCreateTreeViewItem("xx", $idRoot3)
         GUICtrlCreateTreeViewItem("xx", $idRoot3)
         GUICtrlCreateTreeViewItem("xx", $idRoot3)
         GUICtrlCreateTreeViewItem("xx", $idRoot3)
         GUICtrlCreateTreeViewItem("x", $idRoot3)
         GUICtrlCreateTreeViewItem("xx", $idRoot3)
         GUICtrlCreateTreeViewItem("xx", $idRoot3)

    GUISetState(@SW_SHOW, $hGUI)


While 1
    $MSG = GUIGetMsg()
    Select
        Case $MSG = $GUI_EVENT_CLOSE
            Exit
        Case $MSG = $Button1
               $item = GUICtrlRead($idTreeView_1)      ; Get the controlID of the current selected treeview item
                If $item = 0 Then
                    MsgBox(64, "Error", "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
                        GUIDelete($hGUI)
                    EndIf
                EndIf

           ExitLoop
    EndSelect
WEnd
if $item

EndFunc
Func load()

 

Link to comment
Share on other sites

Sorry for the makeover, this is the best i could do, maybe someone else has a better way to do it.

#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiTreeView.au3>
#include <GuiListView.au3>
Opt("GUIEventOptions", 1)
Opt("GUIOnEventMode", 1)
Global $text = ""
Global $dir = "path\to\software"
Local $hGUI, $MSG, $idTreeView_1, $hTreeView_1, $button1, $idRoot1, $idRoot2, $idRoot3, $idRoot1Item1, $idRoot1Item2, $idRoot1Item3, $idRoot1Item4, $item, $Itemtxt, $Itemtxt1, $Itemtxt2, $Itemtxt3, $ItemId, $StrSplit
Local $splt1, $splt2, $splt3
$hGUI = GUICreate("Select System", 314, 314)
$idTreeView_1 = GUICtrlCreateTreeView(6, 6, 300, 260, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT), $WS_EX_CLIENTEDGE)
$hTreeView_1 = ControlGetHandle($hGUI, "", $idTreeView_1)
$button1 = GUICtrlCreateButton("Select", 127, 270, 60, 30)
GUICtrlSetOnEvent(-1, "GetItem")
GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUI()
;=============================================================================
Func GUI()
    $idRoot1 = GUICtrlCreateTreeViewItem("servertype3", $idTreeView_1)
    $idRoot1Item1 = GUICtrlCreateTreeViewItem("folderb", $idRoot1)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item1)
    $idRoot1Item2 = GUICtrlCreateTreeViewItem("foldera", $idRoot1)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item2)
    $idRoot2 = GUICtrlCreateTreeViewItem("servertype3", $idTreeView_1)
    $idRoot1Item3 = GUICtrlCreateTreeViewItem("folder1", $idRoot2)
    GUICtrlCreateTreeViewItem("x xx-x", $idRoot1Item3)
    GUICtrlCreateTreeViewItem("x x x", $idRoot1Item3)
    GUICtrlCreateTreeViewItem("x x", $idRoot1Item3)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item3)
    GUICtrlCreateTreeViewItem("xx xx", $idRoot1Item3)
    GUICtrlCreateTreeViewItem("x x", $idRoot1Item3)
    $idRoot1Item4 = GUICtrlCreateTreeViewItem("folder2", $idRoot2)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
    GUICtrlCreateTreeViewItem("xx", $idRoot1Item4)
    $idRoot3 = GUICtrlCreateTreeViewItem("servertype1", $idTreeView_1)
    GUICtrlCreateTreeViewItem("xx", $idRoot3)
    GUICtrlCreateTreeViewItem("xx", $idRoot3)
    GUICtrlCreateTreeViewItem("xx", $idRoot3)
    GUICtrlCreateTreeViewItem("xx", $idRoot3)
    GUICtrlCreateTreeViewItem("x", $idRoot3)
    GUICtrlCreateTreeViewItem("xx", $idRoot3)
    GUICtrlCreateTreeViewItem("xx", $idRoot3)
EndFunc   ;==>GUI
;=============================================================================
Func GetItem()
    $item = GUICtrlRead($idTreeView_1)
    $ItemId = ControlTreeView($hGUI, '', $idTreeView_1, "GetSelected", $item)
    $Itemtxt = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $ItemId)
    $StrSplit = StringSplit($ItemId, '|')
    If $StrSplit[0] = 3 Then
        $splt1 = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $StrSplit[1])
        $splt2 = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $StrSplit[1] & '|' & $StrSplit[2])
        $splt3 = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $StrSplit[1] & '|' & $StrSplit[2] & '|' & $StrSplit[3])
        MsgBox(64, 'Result', $splt1 & ' - ' & $splt2 & ' - ' & $splt3)
    ElseIf $StrSplit[0] = 2 Then
        $splt1 = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $StrSplit[1])
        $splt2 = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $StrSplit[1] & '|' & $StrSplit[2])
        MsgBox(64, 'Result', $splt1 & ' - ' & $splt2)
    ElseIf $StrSplit[0] = 1 Then
        $splt1 = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $StrSplit[1])
        MsgBox(64, 'Result', $splt1)
    EndIf
EndFunc   ;==>GetItem
;=============================================================================
While 1
    $item = GUICtrlRead($idTreeView_1)
    $ItemId = ControlTreeView($hGUI, '', $idTreeView_1, "GetSelected", $item)
    $Itemtxt = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $ItemId)
    $StrSplit = StringSplit($ItemId, '|')
    If $StrSplit[0] = 3 Then
        $splt1 = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $StrSplit[1])
        $splt2 = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $StrSplit[1] & '|' & $StrSplit[2])
        $splt3 = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $StrSplit[1] & '|' & $StrSplit[2] & '|' & $StrSplit[3])
        ConsoleWrite($splt1 & ' - ' & $splt2 & ' - ' & $splt3 & ' - ' & @MSEC & @CRLF)
    ElseIf $StrSplit[0] = 2 Then
        $splt1 = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $StrSplit[1])
        $splt2 = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $StrSplit[1] & '|' & $StrSplit[2])
        ConsoleWrite($splt1 & ' - ' & $splt2 & ' - ' & @MSEC & @CRLF)
    ElseIf $StrSplit[0] = 1 Then
        $splt1 = ControlTreeView($hGUI, '', $idTreeView_1, "GetText", $StrSplit[1])
        ConsoleWrite($splt1 & ' - ' & @MSEC & @CRLF)
    EndIf
    Sleep(100)
WEnd
;=============================================================================
Func Quit()
    Exit
EndFunc   ;==>Quit
;=============================================================================

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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