Ah, I actually didn’t notice that. Didn’t think to click the icon :):
I did find this one script out there on creative crash that might be a step in the right direction of restoring via script, but I don’t really have experience doing this sort of thing, and this isn’t very clear about what’s going on, so I haven’t been able to reverse engineer it enough to get it to actually do much else.
# Clears maya output window by Zohar
from ctypes import *
#import win32con
user32 = windll.user32
EnumWindowsProc = WINFUNCTYPE(c_int, c_int, c_int)
# Returns handles to windows with matching titles
def get_handle(title, parent = None):
rHwnd = []
def EnumCB(hwnd, lparam, match = title.lower(), rHwnd = rHwnd):
# child
if lparam == 1:
rHwnd.append(hwnd)
return False
title = c_buffer(' ' * 256)
user32.GetWindowTextA(hwnd, title, 255)
if title.value.lower() == match:
rHwnd.append(hwnd)
#print "Matched", title.value
return False
return True
if parent is not None:
user32.EnumChildWindows(parent, EnumWindowsProc(EnumCB), 1)
else:
user32.EnumWindows(EnumWindowsProc(EnumCB), 0)
return rHwnd
def clear():
print "Clearing Maya output window"
out = get_handle("Output Window")
if not out:
print "Output window wasn't found"
else:
ch = get_handle("", out[0])
if ( ch[0] ):
#user32.SendMessageA(ch[0], win32con.EM_SETSEL, 0, -1)
#user32.SendMessageA(ch[0], win32con.EM_REPLACESEL, 1, "")
user32.SendMessageA(ch[0], 0x00B1, 0, -1)
user32.SendMessageA(ch[0], 0x00C2, 1, "")
else:
print "Child window wasn't found"
Seems he’s getting some sort of windows pointer to the window, getting the text area pointer, and sending some sort of message to clear it. I looked up some of the windll.user32 functions to try and run functions on the “out” variable, and there’s like no actual documentation I could find, so I have no clue what the arguments are supposed to be or what the return values mean, so all I’ve managed to do is query whether the window is restored and move it to the foreground when it’s already restored.
Edit- So I got it kind of working after I found the C++ page for the ShowWindow command (I’m not much of a C++ power user), so when I ran windll.user32.ShowWindow(out[0], 9) it will restore. Now to clean things up for my own purposes. If anyone has a more graceful solution later I’d totally prefer it to this though.
Edit 2 - Here’s what I pared it down to:
import ctypes
user32 = ctypes.windll.user32
EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_int)
# Returns handles to windows with matching titles
def get_handle(title, parent=None):
rHwnd = []
def EnumCB(hwnd, lparam, match=title.lower(), rHwnd=rHwnd):
title = ctypes.c_buffer(' ' * 256)
user32.GetWindowTextA(hwnd, title, 255)
if title.value.lower() == match:
rHwnd.append(hwnd)
return False
return True
user32.EnumWindows(EnumWindowsProc(EnumCB), 0)
return rHwnd
# get the output window handle then show it through a C++ command
out = get_handle("Output Window")[0]
user32.ShowWindow(out, 9)