You have to modify the source code of the library in order to do this. Go to the folder where the library was installed and open "__init__.py" file. At the top, after all "win32gui" imports are put, write from win32gui import NIIF_NOSOUND.
After this, go to line 107 and you should see this piece of code:
Shell_NotifyIcon(NIM_MODIFY, (self.hwnd, 0, NIF_INFO,
WM_USER + 20,
hicon, "Balloon Tooltip", msg, 200,
title))
After the "title" parameter, put "NIIF_NOSOUND", it should look like this:
Shell_NotifyIcon(NIM_MODIFY, (self.hwnd, 0, NIF_INFO,
WM_USER + 20,
hicon, "Balloon Tooltip", msg, 200,
title, NIIF_NOSOUND))
If you want to do this alternatively you must further modify the source code, you can add a new argument to show_toast method. Something like this:
# line 121
def show_toast(self, title="Notification", msg="Here comes the message",
icon_path=None, duration=5, threaded=False, sound=False):
And also further send the "sound" parameter:
# line 130
if not threaded:
self._show_toast(title, msg, icon_path, duration, sound)
else:
if self.notification_active():
# We have an active notification, let is finish so we don't spam them
return False
self._thread = threading.Thread(target=self._show_toast, args=(title, msg, icon_path, duration, sound))
self._thread.start()
return True
Then also add the argument to the "hidden" _show_toast method:
# line 63
def _show_toast(self, title, msg,
icon_path, duration, sound):
And make an if else statement to check if you should add "NIIF_NOSOUND" flag:
# line 107
Shell_NotifyIcon(NIM_ADD, nid)
data = (self.hwnd, 0, NIF_INFO,
WM_USER + 20,
hicon, "Balloon Tooltip", msg, 200,
title)
if not sound:
data = data + (NIIF_NOSOUND,)
Shell_NotifyIcon(NIM_MODIFY, data)
This parameter expects a combination of InfoFlags that modify the behavior and appearance of a notification. Read more about NIIF_NOSOUND flag and other flags. Here you can see which "NIIF" flags are available in "pywin32" pywin32 documentation.
You can see more about the parameters of Shell_NotifyIcon function here pywin32 Shell_NotifyIcon.
The second parameter of Shell_NotifyIcon function is a tuple
that represents a "PyNOTIFYICONDATA" object which takes different parameters, you can see more about this object here pywin32 PyNOTIFYICONDATA .
Note: This worked for me on Windows 10.