[function] CreateTreeView

Post your working scripts, libraries and tools
User avatar
Learning one
Posts: 123
Joined: 04 Oct 2013, 13:59
Location: Croatia
Contact:

[function] CreateTreeView

Post by Learning one » 20 Dec 2015, 19:34

Continued from old [function] CreateTreeView thread.
bish01
Posts: 94
Joined: 22 Feb 2016, 03:57

Re: [function] CreateTreeView

Post by bish01 » 22 Feb 2016, 04:12

hi I am new to autohotkey and have no programing experience. author did a great job making it very easy to use and create a simple treeview gui with minimal to no experience.

I have a hard time figuring out how to make an item in a menu run an app or open file or folder on click.
gLabel thing does not seam to work and I do not understand what previous user who replied did to make it work.

could someone help me wirh this?
thanks to all in advance.
bish01
Posts: 94
Joined: 22 Feb 2016, 03:57

Re: [function] CreateTreeView

Post by bish01 » 22 Feb 2016, 04:22

I should mention I tried updated script createMenu
https://autohotkey.com/board/topic/5764 ... reatemenu/
and was able to figure out following replies how to make things run on click but I do not like mouse click menu and prefer gui treeview for what I am after.

cheers.
User avatar
Learning one
Posts: 123
Joined: 04 Oct 2013, 13:59
Location: Croatia
Contact:

Re: [function] CreateTreeView

Post by Learning one » 28 Feb 2016, 20:06

Hi bish01, here's example;

Code: Select all

TvDefinition=
(
Apps		Expand
	Calculator
	Notepad
Folders		Expand
	My Documents
	Program Files
)
Gui, New, +HwndhGui
Gui %hGui%:Add, TreeView, gTreeView h200
CreateTreeView(TvDefinition)
Gui %hGui%:Show
return

GuiClose:
ExitApp

TreeView:
if (A_GuiEvent != "DoubleClick")
	return
TV_GetText(DoubleClickedItemText, A_EventInfo)
if (DoubleClickedItemText="Calculator")
	Run, Calc
else if (DoubleClickedItemText="Notepad")
	Run, Notepad
else if (DoubleClickedItemText="My Documents")
	Run, % A_MyDocuments
else if (DoubleClickedItemText="Program Files")
	Run, % A_ProgramFiles
return

CreateTreeView(TreeViewDefinitionString) {	; by Learning one
	IDs := {} 
	Loop, parse, TreeViewDefinitionString, `n, `r
	{
		if A_LoopField is space
			continue
		Item := RTrim(A_LoopField, A_Space A_Tab), Item := LTrim(Item, A_Space), Level := 0
		While (SubStr(Item,1,1) = A_Tab)
			Level += 1,	Item := SubStr(Item, 2)
		RegExMatch(Item, "([^`t]*)([`t]*)([^`t]*)", match)	; match1 = ItemName, match3 = Options
		if (Level=0)
			IDs["Level0"] := TV_Add(match1, 0, match3)
		else
			IDs["Level" Level] := TV_Add(match1, IDs["Level" Level-1], match3)
	}
}	; http://www.autohotkey.com/board/topic/92863-function-createtreeview/
Post Reply

Return to “Scripts and Functions”