[python-win32] win32gui.SetCapture

Mark Hammond mhammond at skippinet.com.au
Sat Sep 17 04:04:35 CEST 2005


> the following code
>
> pyhdl=win32gui.FindWindow(None,'PythonWin')
> win32gui.SetForegroundWindow(pyhdl)
> win32gui.SetCapture(pyhdl)
>
> results in:
>
> Traceback (most recent call last):
>   File
> "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
> line 310, in RunScript
>     exec codeObject in __main__.__dict__
>   File "C:\test\screen\screen_capture.py", line 51, in ?
>     win32gui.SetCapture(pyhdl)
> error: (0, 'SetCapture', 'No error message is available')
>
> Any hints ?

The return value processing for SetCapture was in error (it was treated as a
boolean function, so would always return None, or raise an error when there
was no previous window that had captured the mouse).  I have fixed that bug
here.  For now, you can simply catch that error and ignore it (the new
version will simply return 0 in that case)

Mark



More information about the Python-win32 mailing list