开发者

Python PyHANDLE object in win32gui

开发者 https://www.devze.com 2023-01-12 08:19 出处:网络
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.

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. http://docs.activestate.com/activepython/2.5/pywin32/PyHANDLE.html

here's the docs for the findwindow method. docs.activestate.com/activepython/2.5/pywin32/win32gui__FindWindow_meth.html

and here's the docs for the method that will not accept int. docs.activestate.com/activepython/2.5/pywin32/win32gu开发者_C百科i__UpdateLayeredWindow_meth.html

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.


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.


pywintypes.HANDLE

PyHANDLE = HANDLE()

Creates a new HANDLE object

0

精彩评论

暂无评论...
验证码 换一张
取 消