Windows-Toasts icon indicating copy to clipboard operation
Windows-Toasts copied to clipboard

Toasts aren't activated after relegation to the action center

Open DatGuy1 opened this issue 3 years ago • 4 comments

DatGuy1 avatar Apr 27 '22 17:04 DatGuy1

The 'pyw' branch supports this based off https://github.com/DatGuy1/Windows-Toasts/issues/35#issuecomment-1462120742, but this should still be done properly with a COM object.

DatGuy1 avatar Mar 24 '23 23:03 DatGuy1

After further investigation this requires registering a COM object. "Translating" the following code snippet from C++/WRL to Python should be implementable in the library, but that's exactly where I'm having issues

class DECLSPEC_UUID(clsid) NotificationActivator WrlSealed
    : public RuntimeClass < RuntimeClassFlags<ClassicCom>,
    INotificationActivationCallback > WrlFinal
{
public:
    virtual HRESULT STDMETHODCALLTYPE Activate(
        _In_ LPCWSTR /*appUserModelId*/,
        _In_ LPCWSTR /*invokedArgs*/,
        /*_In_reads_(dataCount)*/ const NOTIFICATION_USER_INPUT_DATA* /*data*/,
        ULONG /*dataCount*/) override
    {
        std::cout << "activated!";
    }
};
CoCreatableClass(NotificationActivator);

Module<OutOfProc>::Create([] {});
Module<OutOfProc>::GetModule().IncrementObjectCount();
Module<OutOfProc>::GetModule().RegisterObjects();

This is most certainly possible with pywin32, probably through register.UseCommandLine or similar, but as mentioned previously I haven't had any luck. A few of my failed attempts can be found at this gist. Any insight would be appreciated.

DatGuy1 avatar Aug 11 '23 13:08 DatGuy1

Using a custom AUMID means the toast can be activated through the action center, but I'm still not sure if using a COM object is the healthy way of implementing it, so leaving this open for now.

DatGuy1 avatar Aug 13 '23 14:08 DatGuy1