win10toast error : pywintypes.error: (-2147467259, 'Shell_NotifyIcon', 'Unspecified error')



我试图在函数中返回current_time或current_time+1,在函数中我使用win10toast。我的代码以前工作得很好,只是突然停止了工作。我没有做任何事情,也没有更改任何设置。运行以下代码时:

from datetime import datetime, timedelta
from win10toast import ToastNotifier
toast = ToastNotifier()
def At_Time():
global Input_time, Ahead_time
At_time = datetime.now()
Ahead_time = (At_time + timedelta(minutes=1))
if timedelta(seconds=At_time.second) < timedelta(seconds=30):
L = 'Less Than 30 secs... Not changing Current_time'
infoL = str('Current Time:  ' + At_time.strftime("%H:%M:%S") + 'n' + "Input Time:  " + At_time.strftime("%H:%M:%S"))
toast.show_toast(title=L, msg=infoL, duration=7, threaded= True)
Input_time = At_time.strftime("%H:%M")
return Input_time
else:
M = 'More than 30 secs... Adding 1 Min to Current_time'
infoM = str("Current Time:  " + At_time.strftime("%H:%M:%S") + 'n' + "Input Time:  " + Ahead_time.strftime("%H:%M:%S"))
toast.show_toast(title=M, msg=infoM, duration=7, threaded= True)
Input_time = Ahead_time.strftime("%H:%M")
# meeting_row = Row
return Input_time
At_Time()

当运行这个时,我现在得到以下错误:

`Traceback (most recent call last):
File "C:Program FilesPython39libthreading.py", line 954, in _bootstrap_inner self.run()
File "C:Program FilesPython39libthreading.py", line 892, in run self._target(*self._args, **self._kwargs)
File "C:Program FilesPython39libsite-packageswin10toast__init__.py", line 106, in 
show_toast Shell_NotifyIcon(NIM_ADD, nid)
pywintypes.error: (-2147467259, 'Shell_NotifyIcon', 'Unspecified error')`

具体来说,这就是错误:

pywintypes.error: (-2147467259, 'Shell_NotifyIcon', 'Unspecified error')

除了一个问题外,我在任何地方都找不到报告的此问题https://stackoverflow.com/a/65224994/15136959,其中所说的解决方案使用

icon_path=无

这将不起作用,因为它已经是参数的默认值。我假设该错误与Shell_NotifyIcon(NIM_ADD,nid(或Win API错误相关。这个bug/问题在其他地方都没有提及。我可以得到这个错误的原因,或者直接修复吗?

感谢您的帮助和宝贵的时间。。。

编辑:此错误在重新启动后得到修复。同样在重启期间,Windows得到了

"更新Windows,不要关闭PC";

,即使我暂停了Windows更新。但是,仍然有人得到了永久性的修复,甚至是出现这种情况的原因,以避免其他用户将来出现任何问题??

最后,天才能解释吗。。如何通过win10toast同时显示多个通知,而不出现注册类错误?(可选(

我无法用这段代码重现您的问题,但这个线程中出现了类似的问题,我认为这是由python脚本同时触发win10toast引起的。然后,您可以参考:停止所有自动更新Windows 10以自动停止Win10更新。

然后,您可以参考:停止所有自动更新Windows 10以自动停止Win10更新。以自动停止Win10更新。

最后,您不能同时显示多个通知。当一个通知处于活动状态时,第二个通知不会被触发。如果需要,你可以缩短第一次吐司的时间。将第一次吐司的持续时间设置为3秒,这样就可以了。

关于未来是否会同时显示多个通知,微软目前尚未明确表示,未来似乎也不会添加。我认为你可以向微软报告需求。

最新更新