Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PumpEvents - does not work on windows 10 #318

Open
QuadCorei8085 opened this issue Jun 27, 2022 · 1 comment
Open

PumpEvents - does not work on windows 10 #318

QuadCorei8085 opened this issue Jun 27, 2022 · 1 comment

Comments

@QuadCorei8085
Copy link

Using python 3.9.7 and Windows 10.

When trying out a COM DLL that supports events (written in C++) the ShowEvents function detects and prints out the events correctly but attaching an event handler and using PumpEvents(1) does not result in any report.

However same script reports events when I replace "PumpEvents(1)" with "pythoncom.PumpMessages()".

Any idea why i need to pump messages using another python module?

@bennyrowland
Copy link
Contributor

Hi @QuadCorei8085, I have the same Python 3.9.7, Win 10 and using a COM DLL written in C++ that fires events, and I have had no problems with PumpEvents(). Note that you don't need a separate event handler if using ShowEvents(), it will print the event calls itself (I don't know if having a second handler interferes with that in some way). Are you keeping open the connection returned by ShowEvents()? Perhaps share the script (or the minimum example code) and we can try and figure out if there is anything wrong with it. My code looks like this:

import comtypes.client
obj = comtypes.client.CreateObject("MyLibrary.Object")
conn = comtypes.client.ShowEvents(obj)
obj.generate_event()
comtypes.client.PumpEvents(1)

where MyLibrary.Object raises an event in response to the generate_event() method being called. This generates output like:

# event found: IMyObject_MyEvent
Event IMyObject_MyEvent(None)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants