Closed WiliTest closed 7 years ago
Could you please give some details on when you are facing the issue
import pythoncom import win32serviceutil import win32service import win32event import servicemanager import socket import time import sys import pyodbc from win10toast import ToastNotifier
class AlertSertvice(win32serviceutil.ServiceFramework): _svcname = "CoinDumpAlert" _svc_displayname = "Alert" _svcdescription = "Test notification of Windows"
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
socket.setdefaulttimeout(600)
def SvcDoRun(self):
#servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, ''))
#self.main()
rc = None
while rc != win32event.WAIT_OBJECT_0:
#try:
toaster = ToastNotifier()
toaster.show_toast('test',duration=10)
#except:
# servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, sys.exc_info()[0]))
#rc = win32event.WaitForSingleObject(self.hWaitStop, 10*1000)
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
if name == 'main': if len(sys.argv) == 1: servicemanager.Initialize() servicemanager.PrepareToHostSingle(AlertSertvice) servicemanager.StartServiceCtrlDispatcher() else: win32serviceutil.HandleCommandLine(AlertSertvice)
############################### That my code I wrote, after install and start this service, it dump error: (-2147467259, 'Shell_NotifyIcon', 'Unspecified error') to event viewer
Hi, this requires some serious understanding of Win API's which unfortunately I don't possess. Could you please post it on stack overflow?
I don't understand why I closed this topic, since I still get the same issue.
Python WNDPROC handler failed
Traceback (most recent call last):
File "C:\Users\Me\AppData\Local\Programs\Python\Python36\lib\site-packages\win10toast\__init__.py", line 135, in on_destroy
Shell_NotifyIcon(NIM_DELETE, nid)
pywintypes.error: (-2147467259, 'Shell_NotifyIcon', 'Unspecified error')
I suspect the bug happens when another python script trigger win10toast on the same time.
I suspect the bug happens when another python script trigger win10toast on the same time.
Not totally correct. I was running multiple instances of the same file few minutes back and was getting notifications every minute multiple times(from different instances) and no error at all. But right now, suddenly I stopped getting notifications from any of the instances. All are encountering error. If anyone has a fix, please share.
yes i also have this issue with toast notifications and i found that it does happen relatively to running notifications from multiple python files at once . I found that the class "doesn't like" having multiple instances running at the same time and throws an error ... then i made some changes to the code, which are stated here
https://stackoverflow.com/questions/50741455/toastnotifier-object-has-no-attribute-classatom
and now i run this again and recieve this error
(-2147467259, 'Shell_NotifyIcon', 'Unspecified error')
"and read here that its due to the icon not being declared" , so i did as i read and declared icon_path = None
in the show_toast() function call . as such..
toast._show_toast(title, text,icon_path = None, duration=5 )
as described here
https://stackoverflow.com/questions/65223729/error-using-win10toast-pywintypes-error-2147467259-shell-notifyicon-uns
becuase pywin is what created toast , primarily , i took a solution from their book. https://stackoverflow.com/questions/33949186/error-when-trying-to-reuse-windows-notification-class-in-python modifying the main packages file so that notifications can be shown easier.. and from one instance of toast. We want to split it so that every new python program is a fresh toast import. working on doing that now @AaveshK @WiliTest
also i see this doesn't have to do with APIs' @jithurjacob
I catch this error, could you please help me fix?