I've been playing around trying to create a transparent window that will overlay another application. I'm finding the win32 extensions are a bit of a mess, there's win32ui, win32gui, winxpgui, etc. somewhat confusing.
Anyway, I'm trying to pass a handle to a window to this function win32gui.UpdateLayeredWindow
the first argument it wants is a handle, as a pyhandle type.
all the methods to find a handle of a window, all return an int, and not the pyhandle type. even the ones from the same modules. win32gui.findwindow(None, "windowtitle") finds and returns the handle for the window i want, but only in int form and not as a PyHandle.
here's the docs for the object.
here's the docs for the findwindow method.
and here's the docs for the method that will not accept int.
I've even tried using WX to create and find handles for windows, it also only returns int.
there's another function that wants a handle, written by the same people, and it accepts int as a handle. win32api.SetWindowLong
Question is, is there some way to create a PyHANDLE object from the int i receive? I can't figure it out.
2 Answers
As the docs for PyHANDLE say, "Most functions which accept a handle object also accept an integer". Have you tried passing UpdateLayeredWindow the integer?
Basically, a PyHANDLE is just a thin wrapper around an integer, with the extra property that when the PyHANDLE object goes away win32api.CloseHandle will be called on it.
1pywintypes.HANDLE
PyHANDLE = HANDLE()
Creates a new HANDLE object