本脚本来自于Thinkai的博客,仅作为归档。
Gui, Add, TreeView
P1 := TV_Add("P1")
P1C1 := TV_Add("P1C1", P1)
P1C1D1 := TV_Add("P1C1D1", P1C1)
P1C1D2 := TV_Add("P1C1D2", P1C1)
P1C1D3 := TV_Add("P1C1D3", P1C1)
P1C1D2E1 := TV_Add("P1C1D2E1", P1C1D2)
P1C1D2E2 := TV_Add("P1C1D2E2", P1C1D2)
Gui, Show
;获取节点信息
top := TV_GetSelection()
;Clipboard := var_dump(gettvchild(top))
;展开选中下所有节点
;TV_Modify(top,"Expand")
Clipboard := var_dump(expandallchild(top))
return
gettvchild(id){
ret =
if(firstid := TV_GetChild(id)){
ret := [],first := true
ret[firstid] := ""
while(nextid := TV_GetNext(first ? (firstid,first:=false) : nextid)){
ret[nextid] := ""
}
}
for k,v in ret
{
if (TV_GetChild(k))
ret[k] := gettvchild(k)
}
return ret
}
expandallchild(id){
ret := "",TV_Modify(id,"Expand")
if(firstid := TV_GetChild(id)){
ret := [],first := true
ret[firstid] := ""
while(nextid := TV_GetNext(first ? (firstid,first:=false) : nextid)){
ret[nextid] := ""
}
}
for k,v in ret
{
if (TV_GetChild(k))
TV_Modify(k,"Expand"),ret[k] := expandallchild(k)
}
return ret
}
var_dump(obj,level:=0){
static str
if !level
str := ""
if IsObject(obj)
{
space =
loop % level
space .= A_Tab
str .= space "{`n"
for k,v in obj
{
if IsObject(v)
{
str .= space A_Tab (RegExMatch(k,"^\d+$") ? k : """" k """") ":`n"
var_dump(v,level+1)
str := RegExReplace(str,"(*ANYCRLF)\n$",",`n")
}
else
str .= space A_Tab (RegExMatch(k,"^\d+$") ? k : """" k """") ":""" RegExReplace(v,"""","""""") """,`n"
}
str := RegExReplace(str,"(*ANYCRLF),\n*$","`n")
str .= space "}`n"
}
else
str := obj
return str
}
GuiClose: ; 当用户关闭 TreeView 所在的 GUI 窗口时退出脚本.
ExitApp
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。