is there a way to disable notifications when program is running on windows?
Thanks!
is there a way to disable notifications when program is running on windows?
Thanks!
The web page here shows how to disable notifications by editing the registry.
Given that, it should be possible to use the winreg module to query and set the pertinent key.
Here's some sample code. This does not work for me on my current system, because I don't have my permission levels set to allow it ( I get "PermissionError: [WinError 5] Access is denied" on the winreg.SetValueEx
call), so I can't test it, but it should give you some ideas of how to get there. (Modifying the registry will, at a minimum, require running as admin. Last time I needed to do this, I followed the advice at Request UAC elevation from within a Python script? and it worked for me.)
import winreg
app_name = "Microsoft.SkyDrive.Desktop"
notifications_key = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Notifications\\Settings'
keyname = notifications_key + "\\" + app_name
# check its value
regkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, keyname)
try:
enabled_setting = winreg.QueryValueEx(regkey, "Enabled")
notification_enabled = enabled_setting[0] # 1 = enabled; 0 = not enabled
except FileNotFoundError:
notification_enabled = None
winreg.CloseKey(regkey)
print(f"Enabled value: {notification_enabled}")
# disable notifications
regkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, keyname, winreg.KEY_SET_VALUE)
winreg.SetValueEx(regkey, "Enabled", 0, winreg.REG_DWORD, 0)
winreg.CloseKey(regkey)