DatGuy1 / Windows-Toasts

Python library used to send toast notifications on Windows machines
Apache License 2.0
96 stars 6 forks source link

Hiding toasts errors out #143

Open DatGuy1 opened 3 months ago

DatGuy1 commented 3 months ago

This, on paper, should work:

def hide_toast(self, toast: Toast) -> None:
    """
    Removes the specified toast notification from the screen

    :raises: ToastNotFoundError: If the toast could not be found
    """
    toastHistory: ToastNotificationHistory = ToastNotificationManager.history
    targetNotification: Optional[ToastNotification] = next(
        (poppedToast for poppedToast in toastHistory.get_history(self._AUMID) if poppedToast.tag == toast.tag), None
    )

    if targetNotification is None:
        raise ToastNotFoundError(f"Failed to hide toast. Toast {toast} not found")

    self.toastNotifier.hide(targetNotification)

But .hide() raises the following exception: OSError: [WinError -2143420152] The notification cannot be hidden until it has been shown