Custom Protocol Support For Notification itself

This allows for a custom protocol to be called when the Notification itself is called. For example could be used to get around Toast Notifications ability to be dismissed. If the user clicks the notification you could trigger the notification to be displayed again. Also useful to perform the same action as one of the protocols assigned to the action buttons.
This commit is contained in:
ASAJacob 2022-01-22 13:58:55 -07:00 committed by GitHub
parent 9064a66938
commit 4826666254
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 38 deletions

View file

@ -1708,6 +1708,7 @@ if(-NOT[string]::IsNullOrEmpty($Xml)) {
$Scenario = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Scenario'} | Select-Object -ExpandProperty 'Type' $Scenario = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Scenario'} | Select-Object -ExpandProperty 'Type'
$Action1 = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Action1'} | Select-Object -ExpandProperty 'Value' $Action1 = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Action1'} | Select-Object -ExpandProperty 'Value'
$Action2 = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Action2'} | Select-Object -ExpandProperty 'Value' $Action2 = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Action2'} | Select-Object -ExpandProperty 'Value'
$LaunchProtocol = $Xml.Configuration.Option | Where-Object {$_.Name -like 'LaunchProtocol'} | Select-Object -ExpandProperty 'Value'
$GreetGivenName = $Xml.Configuration.Text | Where-Object {$_.Option -like 'GreetGivenName'} | Select-Object -ExpandProperty 'Enabled' $GreetGivenName = $Xml.Configuration.Text | Where-Object {$_.Option -like 'GreetGivenName'} | Select-Object -ExpandProperty 'Enabled'
$MultiLanguageSupport = $Xml.Configuration.Text | Where-Object {$_.Option -like 'MultiLanguageSupport'} | Select-Object -ExpandProperty 'Enabled' $MultiLanguageSupport = $Xml.Configuration.Text | Where-Object {$_.Option -like 'MultiLanguageSupport'} | Select-Object -ExpandProperty 'Enabled'
# Load Toast Notification buttons # Load Toast Notification buttons
@ -2268,7 +2269,7 @@ if ($GreetGivenName -eq "True") {
if (($ActionButton1Enabled -eq "True") -AND ($DismissButtonEnabled -eq "True")) { if (($ActionButton1Enabled -eq "True") -AND ($DismissButtonEnabled -eq "True")) {
Write-Log -Message "Creating the xml for action button and dismiss button" Write-Log -Message "Creating the xml for action button and dismiss button"
[xml]$Toast = @" [xml]$Toast = @"
<toast scenario="$Scenario"> <toast scenario="$Scenario" activationType= "protocol" launch="$LaunchProtocol">
<visual> <visual>
<binding template="ToastGeneric"> <binding template="ToastGeneric">
<image placement="hero" src="$HeroImage"/> <image placement="hero" src="$HeroImage"/>
@ -2304,7 +2305,7 @@ if (($ActionButton1Enabled -eq "True") -AND ($DismissButtonEnabled -eq "True"))
if (($ActionButton1Enabled -ne "True") -AND ($DismissButtonEnabled -ne "True")) { if (($ActionButton1Enabled -ne "True") -AND ($DismissButtonEnabled -ne "True")) {
Write-Log -Message "Creating the xml for no action button and no dismiss button" Write-Log -Message "Creating the xml for no action button and no dismiss button"
[xml]$Toast = @" [xml]$Toast = @"
<toast scenario="$Scenario"> <toast scenario="$Scenario" activationType= "protocol" launch="$LaunchProtocol">
<visual> <visual>
<binding template="ToastGeneric"> <binding template="ToastGeneric">
<image placement="hero" src="$HeroImage"/> <image placement="hero" src="$HeroImage"/>
@ -2338,7 +2339,7 @@ if (($ActionButton1Enabled -ne "True") -AND ($DismissButtonEnabled -ne "True"))
if (($ActionButton1Enabled -eq "True") -AND ($DismissButtonEnabled -ne "True")) { if (($ActionButton1Enabled -eq "True") -AND ($DismissButtonEnabled -ne "True")) {
Write-Log -Message "Creating the xml for no dismiss button" Write-Log -Message "Creating the xml for no dismiss button"
[xml]$Toast = @" [xml]$Toast = @"
<toast scenario="$Scenario"> <toast scenario="$Scenario" activationType= "protocol" launch="$LaunchProtocol">
<visual> <visual>
<binding template="ToastGeneric"> <binding template="ToastGeneric">
<image placement="hero" src="$HeroImage"/> <image placement="hero" src="$HeroImage"/>
@ -2373,7 +2374,7 @@ if (($ActionButton1Enabled -eq "True") -AND ($DismissButtonEnabled -ne "True"))
if (($ActionButton1Enabled -ne "True") -AND ($DismissButtonEnabled -eq "True")) { if (($ActionButton1Enabled -ne "True") -AND ($DismissButtonEnabled -eq "True")) {
Write-Log -Message "Creating the xml for no action button" Write-Log -Message "Creating the xml for no action button"
[xml]$Toast = @" [xml]$Toast = @"
<toast scenario="$Scenario"> <toast scenario="$Scenario" activationType= "protocol" launch="$LaunchProtocol">
<visual> <visual>
<binding template="ToastGeneric"> <binding template="ToastGeneric">
<image placement="hero" src="$HeroImage"/> <image placement="hero" src="$HeroImage"/>
@ -2410,7 +2411,7 @@ if ($ActionButton2Enabled -eq "True") {
Write-Log -Message "This will always enable both action buttons and the dismiss button" -Level Warn Write-Log -Message "This will always enable both action buttons and the dismiss button" -Level Warn
Write-Log -Message "Replacing any previous formatting of the toast xml" -Level Warn Write-Log -Message "Replacing any previous formatting of the toast xml" -Level Warn
[xml]$Toast = @" [xml]$Toast = @"
<toast scenario="$Scenario"> <toast scenario="$Scenario" activationType= "protocol" launch="$LaunchProtocol">
<visual> <visual>
<binding template="ToastGeneric"> <binding template="ToastGeneric">
<image placement="hero" src="$HeroImage"/> <image placement="hero" src="$HeroImage"/>
@ -2449,7 +2450,7 @@ if ($SnoozeButtonEnabled -eq "True") {
Write-Log -Message "This will always enable the action button as well as the dismiss button" -Level Warn Write-Log -Message "This will always enable the action button as well as the dismiss button" -Level Warn
Write-Log -Message "Replacing any previous formatting of the toast xml" -Level Warn Write-Log -Message "Replacing any previous formatting of the toast xml" -Level Warn
[xml]$Toast = @" [xml]$Toast = @"
<toast scenario="$Scenario"> <toast scenario="$Scenario" activationType= "protocol" launch="$LaunchProtocol">
<visual> <visual>
<binding template="ToastGeneric"> <binding template="ToastGeneric">
<image placement="hero" src="$HeroImage"/> <image placement="hero" src="$HeroImage"/>

View file

@ -1688,6 +1688,7 @@ if(-NOT[string]::IsNullOrEmpty($Xml)) {
$Scenario = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Scenario'} | Select-Object -ExpandProperty 'Type' $Scenario = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Scenario'} | Select-Object -ExpandProperty 'Type'
$Action1 = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Action1'} | Select-Object -ExpandProperty 'Value' $Action1 = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Action1'} | Select-Object -ExpandProperty 'Value'
$Action2 = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Action2'} | Select-Object -ExpandProperty 'Value' $Action2 = $Xml.Configuration.Option | Where-Object {$_.Name -like 'Action2'} | Select-Object -ExpandProperty 'Value'
$LaunchProtocol = $Xml.Configuration.Option | Where-Object {$_.Name -like 'LaunchProtocol'} | Select-Object -ExpandProperty 'Value'
$GreetGivenName = $Xml.Configuration.Text | Where-Object {$_.Option -like 'GreetGivenName'} | Select-Object -ExpandProperty 'Enabled' $GreetGivenName = $Xml.Configuration.Text | Where-Object {$_.Option -like 'GreetGivenName'} | Select-Object -ExpandProperty 'Enabled'
$MultiLanguageSupport = $Xml.Configuration.Text | Where-Object {$_.Option -like 'MultiLanguageSupport'} | Select-Object -ExpandProperty 'Enabled' $MultiLanguageSupport = $Xml.Configuration.Text | Where-Object {$_.Option -like 'MultiLanguageSupport'} | Select-Object -ExpandProperty 'Enabled'
# Load Toast Notification buttons # Load Toast Notification buttons
@ -2211,7 +2212,7 @@ if ($GreetGivenName -eq "True") {
if (($ActionButton1Enabled -eq "True") -AND ($DismissButtonEnabled -eq "True")) { if (($ActionButton1Enabled -eq "True") -AND ($DismissButtonEnabled -eq "True")) {
Write-Log -Message "Creating the xml for action button and dismiss button" Write-Log -Message "Creating the xml for action button and dismiss button"
[xml]$Toast = @" [xml]$Toast = @"
<toast scenario="$Scenario"> <toast scenario="$Scenario" activationType= "protocol" launch="$LaunchProtocol">
<visual> <visual>
<binding template="ToastGeneric"> <binding template="ToastGeneric">
<image placement="hero" src="$HeroImage"/> <image placement="hero" src="$HeroImage"/>
@ -2247,7 +2248,7 @@ if (($ActionButton1Enabled -eq "True") -AND ($DismissButtonEnabled -eq "True"))
if (($ActionButton1Enabled -ne "True") -AND ($DismissButtonEnabled -ne "True")) { if (($ActionButton1Enabled -ne "True") -AND ($DismissButtonEnabled -ne "True")) {
Write-Log -Message "Creating the xml for no action button and no dismiss button" Write-Log -Message "Creating the xml for no action button and no dismiss button"
[xml]$Toast = @" [xml]$Toast = @"
<toast scenario="$Scenario"> <toast scenario="$Scenario" activationType= "protocol" launch="$LaunchProtocol">
<visual> <visual>
<binding template="ToastGeneric"> <binding template="ToastGeneric">
<image placement="hero" src="$HeroImage"/> <image placement="hero" src="$HeroImage"/>
@ -2281,7 +2282,7 @@ if (($ActionButton1Enabled -ne "True") -AND ($DismissButtonEnabled -ne "True"))
if (($ActionButton1Enabled -eq "True") -AND ($DismissButtonEnabled -ne "True")) { if (($ActionButton1Enabled -eq "True") -AND ($DismissButtonEnabled -ne "True")) {
Write-Log -Message "Creating the xml for no dismiss button" Write-Log -Message "Creating the xml for no dismiss button"
[xml]$Toast = @" [xml]$Toast = @"
<toast scenario="$Scenario"> <toast scenario="$Scenario" activationType= "protocol" launch="$LaunchProtocol">
<visual> <visual>
<binding template="ToastGeneric"> <binding template="ToastGeneric">
<image placement="hero" src="$HeroImage"/> <image placement="hero" src="$HeroImage"/>
@ -2316,7 +2317,7 @@ if (($ActionButton1Enabled -eq "True") -AND ($DismissButtonEnabled -ne "True"))
if (($ActionButton1Enabled -ne "True") -AND ($DismissButtonEnabled -eq "True")) { if (($ActionButton1Enabled -ne "True") -AND ($DismissButtonEnabled -eq "True")) {
Write-Log -Message "Creating the xml for no action button" Write-Log -Message "Creating the xml for no action button"
[xml]$Toast = @" [xml]$Toast = @"
<toast scenario="$Scenario"> <toast scenario="$Scenario" activationType= "protocol" launch="$LaunchProtocol">
<visual> <visual>
<binding template="ToastGeneric"> <binding template="ToastGeneric">
<image placement="hero" src="$HeroImage"/> <image placement="hero" src="$HeroImage"/>
@ -2353,7 +2354,7 @@ if ($ActionButton2Enabled -eq "True") {
Write-Log -Message "This will always enable both action buttons and the dismiss button" -Level Warn Write-Log -Message "This will always enable both action buttons and the dismiss button" -Level Warn
Write-Log -Message "Replacing any previous formatting of the toast xml" -Level Warn Write-Log -Message "Replacing any previous formatting of the toast xml" -Level Warn
[xml]$Toast = @" [xml]$Toast = @"
<toast scenario="$Scenario"> <toast scenario="$Scenario" activationType= "protocol" launch="$LaunchProtocol">
<visual> <visual>
<binding template="ToastGeneric"> <binding template="ToastGeneric">
<image placement="hero" src="$HeroImage"/> <image placement="hero" src="$HeroImage"/>
@ -2392,7 +2393,7 @@ if ($SnoozeButtonEnabled -eq "True") {
Write-Log -Message "This will always enable the action button as well as the dismiss button" -Level Warn Write-Log -Message "This will always enable the action button as well as the dismiss button" -Level Warn
Write-Log -Message "Replacing any previous formatting of the toast xml" -Level Warn Write-Log -Message "Replacing any previous formatting of the toast xml" -Level Warn
[xml]$Toast = @" [xml]$Toast = @"
<toast scenario="$Scenario"> <toast scenario="$Scenario" activationType= "protocol" launch="$LaunchProtocol">
<visual> <visual>
<binding template="ToastGeneric"> <binding template="ToastGeneric">
<image placement="hero" src="$HeroImage"/> <image placement="hero" src="$HeroImage"/>

View file

@ -27,6 +27,7 @@
<Option Name="HeroImageName" Value="ToastHeroImageDefault.jpg" /> <!-- File name of the image shown in the top of the toast notification --> <Option Name="HeroImageName" Value="ToastHeroImageDefault.jpg" /> <!-- File name of the image shown in the top of the toast notification -->
<Option Name="ActionButton1" Enabled="True" /> <!-- Enables or disables the action button. --> <Option Name="ActionButton1" Enabled="True" /> <!-- Enables or disables the action button. -->
<Option Name="ActionButton2" Enabled="True" /> <!-- Enables or disables the action button. --> <Option Name="ActionButton2" Enabled="True" /> <!-- Enables or disables the action button. -->
<Option Name="LaunchProtocol" Value="microsoft-edge:" /> <!-- Action taken when the notification is clicked. Can be any protocol in Windows -->
<Option Name="DismissButton" Enabled="True" /> <!-- Enables or disables the dismiss button. --> <Option Name="DismissButton" Enabled="True" /> <!-- Enables or disables the dismiss button. -->
<Option Name="SnoozeButton" Enabled="False" /> <!-- Enabling this option will always enable action button and dismiss button --> <Option Name="SnoozeButton" Enabled="False" /> <!-- Enabling this option will always enable action button and dismiss button -->
<Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long --> <Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long -->

View file

@ -32,6 +32,7 @@
<Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long --> <Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long -->
<Option Name="Action1" Value="ToastRunApplicationID:" /> <!-- Action taken when using the Action button. Can be any protocol in Windows --> <Option Name="Action1" Value="ToastRunApplicationID:" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
<Option Name="Action2" Value="https://imab.dk" /> <!-- Action taken when using the Action button. Can be any protocol in Windows --> <Option Name="Action2" Value="https://imab.dk" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
<Option Name="LaunchProtocol" Value="microsoft-edge:" /> <!-- Action taken when the notification is clicked. Can be any protocol in Windows -->
<Text Option="GreetGivenName" Enabled="True" /> <!-- Displays the toast with a personal greeting using the users given name retrieved from AD. Will try retrieval from WMI of no local AD --> <Text Option="GreetGivenName" Enabled="True" /> <!-- Displays the toast with a personal greeting using the users given name retrieved from AD. Will try retrieval from WMI of no local AD -->
<Text Option="MultiLanguageSupport" Enabled="False" /> <!-- Enable support for multiple languages. If set to True, the toast notification will look for the users language culture within the config file --> <Text Option="MultiLanguageSupport" Enabled="False" /> <!-- Enable support for multiple languages. If set to True, the toast notification will look for the users language culture within the config file -->
<en-US> <!-- Default fallback language. This language will be used if MultiLanguageSupport is set to False or if no matching language is found --> <en-US> <!-- Default fallback language. This language will be used if MultiLanguageSupport is set to False or if no matching language is found -->

View file

@ -27,6 +27,7 @@
<Option Name="HeroImageName" Value="ToastHeroImageWindows.jpg" /> <!-- File name of the image shown in the top of the toast notification --> <Option Name="HeroImageName" Value="ToastHeroImageWindows.jpg" /> <!-- File name of the image shown in the top of the toast notification -->
<Option Name="ActionButton1" Enabled="True" /> <!-- Enables or disables the action button. --> <Option Name="ActionButton1" Enabled="True" /> <!-- Enables or disables the action button. -->
<Option Name="ActionButton2" Enabled="True" /> <!-- Enables or disables the action button. --> <Option Name="ActionButton2" Enabled="True" /> <!-- Enables or disables the action button. -->
<Option Name="LaunchProtocol" Value="microsoft-edge:" /> <!-- Action taken when the notification is clicked. Can be any protocol in Windows -->
<Option Name="DismissButton" Enabled="True" /> <!-- Enables or disables the dismiss button. --> <Option Name="DismissButton" Enabled="True" /> <!-- Enables or disables the dismiss button. -->
<Option Name="SnoozeButton" Enabled="False" /> <!-- Enabling this option will always enable action button and dismiss button --> <Option Name="SnoozeButton" Enabled="False" /> <!-- Enabling this option will always enable action button and dismiss button -->
<Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long --> <Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long -->

View file

@ -32,6 +32,7 @@
<Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long --> <Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long -->
<Option Name="Action1" Value="ToastReboot:" /> <!-- Action taken when using the Action button. Can be any protocol in Windows --> <Option Name="Action1" Value="ToastReboot:" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
<Option Name="Action2" Value="https://imab.dk" /> <!-- Action taken when using the Action button. Can be any protocol in Windows --> <Option Name="Action2" Value="https://imab.dk" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
<Option Name="LaunchProtocol" Value="microsoft-edge:" /> <!-- Action taken when the notification is clicked. Can be any protocol in Windows -->
<Text Option="GreetGivenName" Enabled="True" /> <!-- Displays the toast with a personal greeting using the users given name retrieved from AD. Will try retrieval from WMI of no local AD --> <Text Option="GreetGivenName" Enabled="True" /> <!-- Displays the toast with a personal greeting using the users given name retrieved from AD. Will try retrieval from WMI of no local AD -->
<Text Option="MultiLanguageSupport" Enabled="False" /> <!-- Enable support for multiple languages. If set to True, the toast notification will look for the users language culture within the config file --> <Text Option="MultiLanguageSupport" Enabled="False" /> <!-- Enable support for multiple languages. If set to True, the toast notification will look for the users language culture within the config file -->
<en-US> <!-- Default fallback language. This language will be used if MultiLanguageSupport is set to False or if no matching language is found --> <en-US> <!-- Default fallback language. This language will be used if MultiLanguageSupport is set to False or if no matching language is found -->

View file

@ -32,6 +32,7 @@
<Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long --> <Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long -->
<Option Name="Action1" Value="ToastRunUpdateID:" /> <!-- Action taken when using the Action button. Can be any protocol in Windows --> <Option Name="Action1" Value="ToastRunUpdateID:" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
<Option Name="Action2" Value="https://imab.dk" /> <!-- Action taken when using the Action button. Can be any protocol in Windows --> <Option Name="Action2" Value="https://imab.dk" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
<Option Name="LaunchProtocol" Value="microsoft-edge:" /> <!-- Action taken when the notification is clicked. Can be any protocol in Windows -->
<Text Option="GreetGivenName" Enabled="True" /> <!-- Displays the toast with a personal greeting using the users given name retrieved from AD. Will try retrieval from WMI of no local AD --> <Text Option="GreetGivenName" Enabled="True" /> <!-- Displays the toast with a personal greeting using the users given name retrieved from AD. Will try retrieval from WMI of no local AD -->
<Text Option="MultiLanguageSupport" Enabled="False" /> <!-- Enable support for multiple languages. If set to True, the toast notification will look for the users language culture within the config file --> <Text Option="MultiLanguageSupport" Enabled="False" /> <!-- Enable support for multiple languages. If set to True, the toast notification will look for the users language culture within the config file -->
<en-US> <!-- Default fallback language. This language will be used if MultiLanguageSupport is set to False or if no matching language is found --> <en-US> <!-- Default fallback language. This language will be used if MultiLanguageSupport is set to False or if no matching language is found -->

View file

@ -32,6 +32,7 @@
<Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long | alarm --> <Option Name="Scenario" Type="reminder" /> <!-- Possible values are: reminder | short | long | alarm -->
<Option Name="Action1" Value="ToastReboot:" /> <!-- Action taken when using the Action button. Can be any protocol in Windows --> <Option Name="Action1" Value="ToastReboot:" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
<Option Name="Action2" Value="https://imab.dk" /> <!-- Action taken when using the Action button. Can be any protocol in Windows --> <Option Name="Action2" Value="https://imab.dk" /> <!-- Action taken when using the Action button. Can be any protocol in Windows -->
<Option Name="LaunchProtocol" Value="microsoft-edge:" /> <!-- Action taken when the notification is clicked. Can be any protocol in Windows -->
<Text Option="GreetGivenName" Enabled="True" /> <!-- Displays the toast with a personal greeting using the users given name retrieved from AD. Will try retrieval from WMI of no local AD --> <Text Option="GreetGivenName" Enabled="True" /> <!-- Displays the toast with a personal greeting using the users given name retrieved from AD. Will try retrieval from WMI of no local AD -->
<Text Option="MultiLanguageSupport" Enabled="False" /> <!-- Enable support for multiple languages. If set to True, the toast notification will look for the users language culture within the config file --> <Text Option="MultiLanguageSupport" Enabled="False" /> <!-- Enable support for multiple languages. If set to True, the toast notification will look for the users language culture within the config file -->
<en-US> <!-- Default fallback language. This language will be used if MultiLanguageSupport is set to False or if no matching language is found --> <en-US> <!-- Default fallback language. This language will be used if MultiLanguageSupport is set to False or if no matching language is found -->