查看窗体结构。当想改系统的窗口时。或想参照学习一下时。列出窗口的层级结构看看是不错的。简单功能没写UI。直接调用就行了。
最后更新时间 2013-11-23 07:25:32
//例子
printWindowUI(findWindowChildren(findWindowByTitle("UV Texture Editor")));
//通过窗体的 标签 找 窗体名称
proc string findWindowByTitle( string $windowTitle )
{
// Default empty string to denote that no matching window was found.
//
string $windowUI = "";
string $allWindows[] = `lsUI -type "window"`;
for ( $w in $allWindows )
{
// Compare the specified title with that queried from each window.
//
if ( $windowTitle == `window -q -title $w` )
{
// Found it!
//
$windowUI = $w;
break;
}
}
return $windowUI;
}
//显示窗体的子元素
proc string[] findWindowChildrenLayout( string $windowUI )
{
string $pattern = $windowUI + "*";
string $controls[] = `lsUI -l -cl`;
string $child[];
for ( $ui in $controls )
{
if ( `gmatch $ui $pattern` )
{
$child[`size $child`] = $ui;
}
}
return sort($child);
}
//显示窗体的子元素
proc string[] findWindowChildren( string $windowUI )
{
string $pattern = $windowUI + "*";
string $controls[] = `lsUI -l -ctl`;
string $child[];
for ( $ui in $controls )
{
if ( `gmatch $ui $pattern` )
{
$child[`size $child`] = $ui;
}
}
return sort($child);
}
//输出显示
proc int printWindowUI(string $windowAllChildren[])
{
string $child;
string $buffer[];
print("--------------------------------------------------------------------------\n");
print(`match "^[^\|]*" $windowAllChildren[0]`+" : \n");
for ($child in $windowAllChildren)
{
int $i,$n = `tokenize $child "|" $buffer` - 1;
for ($i = 0 ;$i < $n ; $i++)
{
print("| ");
}
print("+ " + `match "[^|]*$" $child` + "\n");
}
print("--------------------------------------------------------------------------\n");
return 1;
}