Find the last window created in Maya?
<p>I was wondering if there is any way to find the name of the last window created in Maya, knowing that I can't add any information to the window itself before that... I checked in both the <code>cmds</code> and API but couldn't find anything. Maybe in PyQt but I don't know much about it.</p>

<p>I'm looking for any solution. Thanks</p>

<p>Here is what I came up with, it's surely not the "cleanest" solution but it works!</p>

<pre><code># List all the currently opened windows
uisBefore = cmds.lsUI (wnd = True)

# Execute the function which may or may not create a window
func(*args, **kwargs)

# List all the opened windows again
uisAfter = cmds.lsUI (wnd = True)

# Find all the windows that were opened after executing func()
newUIs = [ui for ui in uisAfter if ui not in uisBefore]
</code></pre>

python maya