Windos / BurntToast

Module for creating and displaying Toast Notifications on Microsoft Windows 10.
MIT License
1.43k stars 122 forks source link

Is it possible to add the custom app to the focus assist priority list and would doing this making burnt toast notifications obey the focus assist rules? #112

Open Windos opened 4 years ago

Windos commented 4 years ago

Is it possible to add the custom app to the focus assist priority list and would doing this making burnt toast notifications obey the focus assist rules?

Originally posted by @Cenwulf in https://github.com/Windos/BurntToast/issues/96#issuecomment-684017131

Windos commented 4 years ago

Hey @Cenwulf, just moved this over to a new issue. Will pop some comments here in a sec

Windos commented 4 years ago

Assuming you've created a custom AppID (as referenced in #96) it'll show up in the list of apps in the Settings app. (n.b. you'll have needed to use it for a toast notification at least once first)

This means you can add it to your "priority" list in the Focus assist settings.

Settings app -> System -> Focus assist -> Customize your priority list

Focus assist settings app page

Once there, scroll down to apps and click Add an app:

Priority list settings

In my case I've registered a "BurntToast" app id

BurntToast is on the list

This will mean toasts with that ID will still be displayed if you have focus assist set to "Priority only" but if you crank it up to "Alarms only" it won't. We do have an option here though; you can specify that your toast notification is for an alarm.

$Text1 = New-BTText -Content 'This is an alarm'
$ImagePath = 'C:\Program Files\PowerShell\7-preview\assets\Powershell_av_colors.ico'
$Image1 = New-BTImage -Source $ImagePath -AppLogoOverride -Crop None

$Audio1 = New-BTAudio -Source 'ms-winsoundevent:Notification.Looping.Alarm6'

$Binding1 = New-BTBinding -Children $Text1 -AppLogoOverride $Image1
$Visual1 = New-BTVisual -BindingGeneric $Binding1

$Content1 = New-BTContent -Visual $Visual1 -Audio $Audio1 -Scenario Alarm

Submit-BTNotification -Content $Content1

The key is the "Scenario" on New-BTContent. Also, note that when this is what you're setting the scenario too only "looping" sounds are allowed (e.g. 'ms-winsoundevent:Notification.Looping.Alarm6') if you choose something else it'll default to the first alarm sound.

Cenwulf commented 4 years ago

Thanks for the speedy reply!

You've made realise I can also add Windows PowerShell to the priority list and get the desired behaviour without the need to install a custom AppID.

I think the bit I was missing was that I needed to run BurntToast at least once to get PowerShell to appear in the list of available apps.

Thanks again for all your help.

Windos commented 4 years ago

No prob! Yeah the reason for running once is that it injects some stuff into the registry. Interestingly it then also shows up on the notifications settings page and from there you can specify how many to show in the Action Center and how important they are (so which other notifications they'll appear "above".)

I'll leave this issue open, as I'm planning on using it as a prompt for a blog post/documentation on the topic.

Thanks for reaching out!

ezjurgen commented 1 year ago

@Windos @Cenwulf Hey Guys, would you share the powershell code to make powershell a priority app? I just tried while 'Do not disturb' enabled, then using New-BurntToastNotification @splat (Alarm10) and Submit-BTNotification -Content $Content1(also alarm10 + scenario=Alarm) an neither pop up.

I am using BT right after win11 provisioning and on first login some scripts launch needing user input, a toast alarm would grab their attention. But all notifications go to the message center without 'toasting'. It seems this is due to windows going in to DND mode the first hour after major windows updates (CU, LCU..) , and it sees an installation as a major update I guess.

Would be great if I could get BT on the priolist or disable Do Not Disturb altogether programmaticly on first login.