Forum: Poser - OFFICIAL


Subject: Poser file name via Python

3doutlaw opened this issue on Jun 26, 2013 · 11 posts


3doutlaw posted Wed, 26 June 2013 at 8:46 PM

Thanks ockham, but I fear the whole time-based thing, though you are a master for figuring that out.  I've been googling and testing a while now, and I think I came up with a good option.

It basically runs through the open windows, looking for one with "Smith Micro Poser" in the window title, then removes that part of the string.  This would work as long as there is only one Poser window open, that has "Smith Micro Poser" in the window title.

Here is the link that got me there...

        EnumWindows = ctypes.windll.user32.EnumWindows
        EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
        GetWindowText = ctypes.windll.user32.GetWindowTextW
        GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
        IsWindowVisible = ctypes.windll.user32.IsWindowVisible
 
        global windowtitle
        def foreach_window(hwnd, lParam):
            if IsWindowVisible(hwnd):
                length = GetWindowTextLength(hwnd)
                buff = ctypes.create_unicode_buffer(length + 1)
                GetWindowText(hwnd, buff, length + 1)
                if "Smith Micro Poser" in buff.value:
                                    windowtitle = buff.value
                                    print windowtitle[:-20]
            return True
        EnumWindows(EnumWindowsProc(foreach_window), 0)