How to assign a hotkey to enable/disable Focus Assist on Windows 10/11?

Solution 1:

AutoHotkey script, first one I've ever done :)

; ^6=Ctrl+6 activates script. #f=Win+F which would take over a builtin hotkey opens Feedback Hub and screenshot
^6::
; Keys sequence: Win+B, Left, Menu/Right-click key, Down 2x, Enter, Down=Priority (2x=Alarm), Enter
; Win+B Sets focus for the Show hidden icons dropdown menu: https://support.microsoft.com/en-us/windows/keyboard-shortcuts-in-windows-dcc61a57-8ff0-cffe-9796-cb9706c75eec
Send, #b
Sleep, 500 ; wait 0.5sec since PC's need a moment to bring up menus sometimes
Send, {Left}{AppsKey}
Sleep, 500
Send, {Down 2}{Enter}{Down}{Enter}{Esc} ; Esc closes notifications bar
; Send, {Down 2}{Enter}{Down 2}{Enter} ; uncomment this line for Alarms only then comment above line
return

; Turn off Windows Focus Assist with Ctrl+0
^0::
Send, #b
Sleep, 500
Send, {Left}{AppsKey}
Sleep, 500
Send, {Down 2}{Enter 2}{Esc}
return
; VARIATION2: Win+I, focus assist, Down, Enter, Tab 3x=Priority (4x=Alarm), Spacebar, Alt+F4
; VARIATION3: Win+A, Shift+Tab 3x, Enter, Tab 2x, Down 2x, Right 3x, Enter=Priority Mode, Enter 2x=Alarm

Solution 2:

The policy setting that controls Toast Notifications is particularly difficult to undo. It is controlled by the Local Group Policy Editor at User Configuration > Administrative Templates > Start Menu and Taskbar > Notifications, policy "Turn off toast notifications". It modifies various registry entries, but also several files, one of whom is in binary format, so not user-modifiable. This is why a Microsoft utility is required for setting it.

I will give below two commands for enabling and disabling Toast Notifications. You may put them in two .bat files and assign them hotekeys, or alternatively use AutoHotkey.

Prerequisite

Download the LGPO utility, the Local Group Policy Object Utility, from Microsoft Security Compliance Toolkit 1.0.

When pressing the Download button, select "LGPO.zip" and click Next to download it. Unzip the archive to obtain this utility in LGPO.exe.

Input files

Create two text files as follows (you may use your own file-names):

1. disable_toast_notifications.txt

User
SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications
NoToastApplicationNotification
DWORD:1

2. enable_toast_notifications.txt

User
SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications
NoToastApplicationNotification
DWORD:0

Disable Toast Notifications

Use the following command in Run as Administrator mode:

\path\LGPO.exe /t \path\disable_toast_notifications.txt

Enable Toast Notifications

Use the following command in Run as Administrator mode:

\path\LGPO.exe /t \path\enable_toast_notifications.txt

For more information see the article
How to use LGPO.exe to modify lgpo settings (with lgpo examples).