简体   繁体   中英

Disable notifications when software is running On windows 10

is there a way to disable notifications when a software is running?

I am using tkinter (if it's relevant).

Os is windows 10

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM