[python-win32] PumpMessages in main thread called by embedded Python causes crash

Mark Hammond mhammond at skippinet.com.au
Mon Apr 30 02:51:03 CEST 2012


I'm afraid my only other idea is to contact the vendor of the other app 
and see if they can shed any light on the problem...

Cheers,

Mark

On 30/04/2012 10:49 AM, reckoner wrote:
>
>
> On 4/29/2012 3:48 PM, Mark Hammond wrote:
>> On 30/04/2012 1:07 AM, reckoner wrote:
>>> Thanks for your reply.
>>>
>>> Yes, the app works fine if I don't PumpMessages in my own code. There is
>>> no console that the application fires up when it runs the embedded
>>> Python code. In this situation, how do I (or, can I?) pump for my own
>>> messages if the application is doing some other kind of event loop, as
>>> you describe?
>>
>> The event loop isn't generally where you handle messages - messages are
>> generally handled in a WndProc or similar (ie, by using something like
>> win32gui and its message handling support).  You might also want to look
>> into hooking messages (pythonwin has some support for that, and another
>> package called PyHook might also help).
>>
>> Mark
>>>
>
> Yes, I use PyHook on another project, but here I need to hook more than
> mouse and keyboard messages. I need window-open/close, etc. According to
> this thread:
>
> http://stackoverflow.com/questions/6458812/python-ctypes-setwindowshookex-callback-function-never-called
>
>
> this is not possible directly and I have been successful using the pyAA
> (Microsoft Active Accessibility) bindings to catch these other messages,
> and this works beautifully otherwise, except for this case where the
> embedded application (not a GUI, BTW) will not let me pump messages to
> flush out the events that pyAA can catch.
>
> Any other ideas? The only other idea I have is to create a separate
> Python process that will listen for specific messages using pyAA and
> then return output on a socket that the application's embedded Python
> can later query.
>
> Thanks again. (I read your great book by the way!)
>
>
>
>
>




More information about the python-win32 mailing list