Search code examples
.netwinapi.net-corepywin32event-log

How to detect windows action center events programatically?


I posted before asking how to do this in Python, but I'm not sure python even has an API for this.

I'm trying to detect Windows Action Center events. This Python code will detect some events, but is unreliable and can't determine exactly the type of event:

h = win32evtlog.OpenEventLog(None, "System")
flags = win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ
for record in win32evtlog.ReadEventLog(h, flags, 0):
    if record.EventID == 10016:
        print("it's a google calendar event (or something similar)!")

However, other events, such as Google chat events from Chrome, don't seem to cause a Windows system event, even though they show up in Action Center.

Is there any way to programmatically detect Windows Action Center events, in either C/C++ or Python (preferably), or even a .NET language like C#?


Solution

  • I think I can use a listener and listen for Toast notifications. But I'm realizing I actually don't want the dependency on .NET so I might try to figure out how to do it in C/C++ or Python.

    EDIT: After I wrote a draft in C# I converted it to Python here, but not all events are showing up yet.