Detect Items Selected In TreeView Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
roonyrooxcess
Posts: 61
Joined: 20 Nov 2020, 21:29

Detect Items Selected In TreeView  Topic is solved

15 Oct 2022, 11:40

Hi! I'm trying to figure out how to detect items selected in a treeview.

Ie if a person selects tree2 child1, I need to detect both the "tree 2" selected & its "child 1". I've tried googling this, but cant find much info ...

Thanks!

My code :

Code: Select all

Gui, Add, TreeView
Tree1 := TV_Add("First parent")
Tree1Child := TV_Add("Tree1Child", Tree1)  ; Specify P1 to be this item's parent.

Tree2 := TV_Add("Second parent")
Tree2Child1 := TV_Add("Tree2Child1", Tree2)
Tree2Child2 := TV_Add("Tree2Child2", Tree2)
Tree2Child3 := TV_Add("Tree2Child3", Tree2)

Gui, Show  ; Show the window and its TreeView.
return

GuiClose:  ; Exit the script when the user closes the TreeView's GUI window.
ExitApp
roonyrooxcess
Posts: 61
Joined: 20 Nov 2020, 21:29

Re: Detect Items Selected In TreeView

15 Oct 2022, 11:54

Found it:

Code: Select all

/::
{


GetSelectedTextID:=TV_GetSelection()

GetSelectedText:=TV_GetText(OutputVar, GetSelectedTextID)
    

msgbox % OutputVar

}
Return
garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: Detect Items Selected In TreeView

16 Oct 2022, 10:24

thank you , it works with hotkey , I tried with gLabel > TreeEvent
a question : at first run 'First parent' is selected and it runs to TreeEvent and shows 'First Parent'
How to avoid , not run to TreeEvent at first run, only when click on row/tree ?

Code: Select all

#Warn
Gui,1:default
i:=0
Gui, Add, TreeView,backgroundGray vTV1  gTreeEvent
Tree1 := TV_Add("First parent")
  Tree1ChildA := TV_Add("Tree1ChildA", Tree1)
;---
Tree2 := TV_Add("Second parent")
  Tree2Child1 := TV_Add("Tree2Child1", Tree2)
  Tree2Child2 := TV_Add("Tree2Child2", Tree2)
  Tree2Child3 := TV_Add("Tree2Child3", Tree2)
;---
Gui, Show 
return
;-----------
GuiClose:
ExitApp
;-----------
;k::
TreeEvent:
Gui, 1:TreeView, TV1
i++
if (i=1)
    return                ;- return at first run when script started
if A_GuiEvent <> S
   return	
GetSelectedText:=TV_GetText(OutputVar,A_EventInfo)
msgbox % OutputVar
Return
;===========

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: hitman, peter_ahk and 171 guests