PDA

View Full Version : Get Active Window Name


Kel Solaar
01-14-2008, 07:54 PM
Hello :)

I want to get the window name from where the command has been launched (last current active window), is there a way for the PrintCurrentWindowName() to get the active window? (Instead of passing the window name by the procedure arguments)

string $window = `window`;
columnLayout -adjustableColumn true;

string $menuBarLayout = `menuBarLayout`;

menu -label "Print";

menuItem -label "Current Window Name" -command "PrintCurrentWindowName";

setParent ..;

setParent ..;

showWindow $window;



global proc PrintCurrentWindowName()

{

print "Print Current Window Name !";

}

phlam
01-17-2008, 03:38 PM
By 'window', do you mean the active panel, like the outliner or a viewport ?

In this case, the modified procedure should work


global proc PrintCurrentWindowName()

{
string $currentPanel = getPanel ("-withFocus");
print ("Print Current Window Name:" + $currentPanel + "\n");
}

hibigibees
01-24-2008, 05:23 PM
hi there,

global proc foo()
{
//if the funtion itself has its own name in a variable:
string $function = "foo()";
string $win = "";

for($each in `lsUI -l -menuItems`)
{
if(`menuItem -q -c $each` == $function)
{
$win = $each;
print $each; break; // u can remove break to find
// all menuItems which call this function //
}

string $buf[]; tokenize $win "|" $buf;
print ("\nWindow Name: " + $buf[0]);
}

}

-- sriram

CGTalk Moderation
01-24-2008, 05:23 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.