ledigeine Posted May 21, 2012 Share Posted May 21, 2012 Hello, been working on this utility for a while now and just found out there is a Tree UI option so i'm messing with that now. It could make everything a lot easier. So i have my tree here, 3 main options with several versions under them. Then country options under each version. How would i return a value for the item that is highlighted? So i would need to see its, Testassigned/12.0/US. Because based on each item I will need to pull a value from an XML file so i can map 2 drives correctly. Thank you for any help you can give. Link to comment Share on other sites More sharing options...
spudw2k Posted May 21, 2012 Share Posted May 21, 2012 I once made a function to do that, but I am struggling to find where it is. There are functions in the GUICtrlTreeView UDF that will get you there. I can't remember the functions but the logic goes like this. One function will return the id/index of the selected item. Another will retrieve the text value if the item. Then a function determines the selected id/indexes parent, Rinse repeat until no more parents are found. If I come across my _TreeToPath function I'll post it. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
ledigeine Posted May 21, 2012 Author Share Posted May 21, 2012 Thanks! Yeah before this i was using radio buttons and lists, I think a tree will be way easier for a user to understand. And this way there wont be a bunch of different conditions its all based on one element. I should see if theres a way to make the main parts of the tree not selectable, so a user would know you can only pick the end of the tree or something like that. Link to comment Share on other sites More sharing options...
water Posted May 21, 2012 Share Posted May 21, 2012 Please have a look at my _AD_Example_GetOUTreeView example script. It displays an Active Directory treeview of all OUs and when an OU is selected it returns the name plus the FQDN. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
spudw2k Posted May 21, 2012 Share Posted May 21, 2012 (edited) $selection = _GUICtrlTreeView_GetSelection($hWnd) $txt = _TreePath($hWnd,$selection) Func _TreePath($hWnd, $item) ;Determine full path of selected item in TreeView $txt = _GUICtrlTreeView_GetText($hWnd, $item) Do $parent = _GUICtrlTreeView_GetParentHandle($hWnd, $item) If $parent > 0 Then $txt = _GUICtrlTreeView_GetText($hWnd, $parent) & "" & $txt $item = $parent EndIf Until $parent = 0 Return StringTrimLeft($txt,StringInstr($txt,"")) EndFunc ;==>;_TreePath edit: 1000th post. Edited May 22, 2012 by spudw2k ledigeine 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
ledigeine Posted May 21, 2012 Author Share Posted May 21, 2012 Thank you both, very very helpful! I might get this utility working one day! Link to comment Share on other sites More sharing options...
ledigeine Posted May 21, 2012 Author Share Posted May 21, 2012 $selection = _GUICtrlTreeView_GetSelection($treeview) $txt = _TreePath($treeview,$selection) Func _TreePath($treeview, $item) ;Determine full path of selected item in TreeView $txt = _GUICtrlTreeView_GetText($treeview, $item) Do $parent = _GUICtrlTreeView_GetParentHandle($treeview, $item) If $parent > 0 Then $txt = _GUICtrlTreeView_GetText($treeview, $parent) & "\" & $txt $item = $parent EndIf Until $parent = 0 Return StringTrimLeft($txt,StringInstr($txt,"\")) EndFunc ;==>;_TreePathI got this going on, didnt really have to change much thanks to spudw2k. When running this on my script im getting an issue. Its pulling the 'parent' i think youd call it, then the child as well but its not pulling the childs child... hah.Heres a screen shot.So I would really need it to display Testassigned then 12.0 then US. Even if there was another option under US i would also need that displayed.How could i make it keep checking and reading until its at the end of the tree? Link to comment Share on other sites More sharing options...
spudw2k Posted May 21, 2012 Share Posted May 21, 2012 (edited) Can you provide more code to test with? I'm not sure why it is producing the string in that manner. Edited May 21, 2012 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
ledigeine Posted May 22, 2012 Author Share Posted May 22, 2012 expandcollapse popup#include <GuiTreeView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> Global $txt, $item EBTAM() Func EBTAM() Global $treeview, $mapB, $ass, $app, $shp GUICreate("EB TAM", 600, 400) GUISetState(@SW_SHOW) $treeview = GUICtrlCreateTreeView(20, 15, 560, 325, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) $ass = GUICtrlCreateTreeViewItem("Test Assigned", $treeview) $app = GUICtrlCreateTreeViewItem("Testing Approved", $treeview) $shp = GUICtrlCreateTreeViewItem("Shipped", $treeview) testassigned() testingapproved() shipped() $mapB = GUICtrlCreateButton("&Map", 20, 350, 120, 40) ;~ GUICtrlSetState($ass, $GUI_EXPAND) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $mapB MsgBox(0, "node selected", "Node: " & _TreePath($treeview, $item)) EndSwitch WEnd EndFunc $selection = _GUICtrlTreeView_GetSelection($treeview) $txt = _TreePath($treeview,$selection) Func _TreePath($treeview, $item) ;Determine full path of selected item in TreeView $txt = _GUICtrlTreeView_GetText($treeview, $item) Do $parent = _GUICtrlTreeView_GetParentHandle($treeview, $item) If $parent > 0 Then $txt = _GUICtrlTreeView_GetText($treeview, $parent) & "\" & $txt $item = $parent EndIf Until $parent = 0 Return StringTrimLeft($txt,StringInstr($txt,"\")) EndFunc ;==>;_TreePath thats most of it, just didnt wana put the fuctions for making the items in the list... they are long ha. Heres a little taste of it: Func testassigned() Local $120, $111, $110, $108, $107, $106, $105, $104, $103, $102, $101, $100, $94, $93, $92, $91 $120 = GUICtrlCreateTreeViewItem("12.0", $ass) GUICtrlCreateTreeViewItem("US", $120) GUICtrlCreateTreeViewItem("CA", $120) GUICtrlCreateTreeViewItem("UK", $120) Link to comment Share on other sites More sharing options...
spudw2k Posted May 22, 2012 Share Posted May 22, 2012 This seems to work. Had to modify _TreePath slightly. expandcollapse popup#include <GuiTreeView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> Global $txt, $item EBTAM() Func EBTAM() Global $treeview, $mapB, $ass, $app, $shp GUICreate("EB TAM", 600, 400) $treeview = GUICtrlCreateTreeView(20, 15, 560, 325, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) $ass = GUICtrlCreateTreeViewItem("Test Assigned", $treeview) $app = GUICtrlCreateTreeViewItem("Testing Approved", $treeview) $shp = GUICtrlCreateTreeViewItem("Shipped", $treeview) $120 = GUICtrlCreateTreeViewItem("12.0", $ass) GUICtrlCreateTreeViewItem("US", $120) GUICtrlCreateTreeViewItem("CA", $120) GUICtrlCreateTreeViewItem("UK", $120) $mapB = GUICtrlCreateButton("&Map", 20, 350, 120, 40) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $mapB MsgBox(0, "node selected", "Node: " & _TreePath($treeview, $item)) EndSwitch WEnd EndFunc Func _TreePath($treeview, $item) ;Determine full path of selected item in TreeView $item = _GUICtrlTreeView_GetSelection($treeview) $txt = _GUICtrlTreeView_GetText($treeview, $item) Do $parent = _GUICtrlTreeView_GetParentHandle($treeview, $item) $txt = _GUICtrlTreeView_GetText($treeview, $parent) & "" & $txt $item = $parent Until $parent = 0 Return StringTrimLeft($txt,StringInstr($txt,"")) EndFunc ;==>;_TreePath ledigeine and dogisay 2 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
ledigeine Posted May 22, 2012 Author Share Posted May 22, 2012 Wow there we go thanks so much! I think i should be able to figure out how to split the string up so i get the pieces i need. Then refer to the xml pulling script to match each part with a section of a path that this uitliy will map a drive to. Thank you again! 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