Added a Snooze switch
Added a SNooze switch to allow users to Snooze the toast. Default snooze timer is set to 1min but can be changed in the XML Section of Toast_Notify.ps1 line 190 Also fixed an error in resolving the logged on user
This commit is contained in:
parent
070b85950e
commit
a55d2aa624
2 changed files with 48 additions and 3 deletions
|
|
@ -6,4 +6,5 @@
|
||||||
<EventText>We are currently experiencing problems with all our systems. We are drinking coffee will provide an update shortly. Thank you for your patience</EventText>
|
<EventText>We are currently experiencing problems with all our systems. We are drinking coffee will provide an update shortly. Thank you for your patience</EventText>
|
||||||
<ButtonTitle>Details</ButtonTitle>
|
<ButtonTitle>Details</ButtonTitle>
|
||||||
<ButtonAction>https://byteben.com</ButtonAction>
|
<ButtonAction>https://byteben.com</ButtonAction>
|
||||||
|
<SnoozeTitle>Snooze</SnoozeTitle>
|
||||||
</ToastContent>
|
</ToastContent>
|
||||||
|
|
@ -36,6 +36,7 @@ Toast_Notify.ps1
|
||||||
Param
|
Param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $False)]
|
[Parameter(Mandatory = $False)]
|
||||||
|
[Switch]$Snooze,
|
||||||
[String]$XMLScriptDirSource = "CustomMessage.xml",
|
[String]$XMLScriptDirSource = "CustomMessage.xml",
|
||||||
[String]$XMLOtherSource
|
[String]$XMLOtherSource
|
||||||
|
|
||||||
|
|
@ -82,6 +83,7 @@ If ($XMLValid -eq $True) {
|
||||||
$EventText = $XMLToast.ToastContent.EventText
|
$EventText = $XMLToast.ToastContent.EventText
|
||||||
$ButtonTitle = $XMLToast.ToastContent.ButtonTitle
|
$ButtonTitle = $XMLToast.ToastContent.ButtonTitle
|
||||||
$ButtonAction = $XMLToast.ToastContent.ButtonAction
|
$ButtonAction = $XMLToast.ToastContent.ButtonAction
|
||||||
|
$SnoozeTitle = $XMLToast.ToastContent.SnoozeTitle
|
||||||
|
|
||||||
#ToastDuration: Short = 7s, Long = 25s
|
#ToastDuration: Short = 7s, Long = 25s
|
||||||
$ToastDuration = "long"
|
$ToastDuration = "long"
|
||||||
|
|
@ -99,7 +101,7 @@ If ($XMLValid -eq $True) {
|
||||||
$Launcherid = "MSEdge"
|
$Launcherid = "MSEdge"
|
||||||
|
|
||||||
#Get last(current) logged on user
|
#Get last(current) logged on user
|
||||||
$LoggedOnUserPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI"
|
$LoggedOnUserPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\LastLoggedOnDisplayName"
|
||||||
If (!(Test-Path $LoggedOnUserPath)) {
|
If (!(Test-Path $LoggedOnUserPath)) {
|
||||||
Try {
|
Try {
|
||||||
$Firstname = $Null
|
$Firstname = $Null
|
||||||
|
|
@ -127,7 +129,9 @@ If ($XMLValid -eq $True) {
|
||||||
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
|
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
|
||||||
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
|
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
|
||||||
|
|
||||||
#Build XML Template
|
If (!$Snooze) {
|
||||||
|
|
||||||
|
#Build XML Template when Snooze Timer is not specified
|
||||||
[xml]$ToastTemplate = @"
|
[xml]$ToastTemplate = @"
|
||||||
<toast duration="$ToastDuration" scenario="reminder">
|
<toast duration="$ToastDuration" scenario="reminder">
|
||||||
<visual>
|
<visual>
|
||||||
|
|
@ -156,7 +160,47 @@ If ($XMLValid -eq $True) {
|
||||||
</actions>
|
</actions>
|
||||||
</toast>
|
</toast>
|
||||||
"@
|
"@
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
#Build XML Template when Snooze Timer is specified
|
||||||
|
[xml]$ToastTemplate = @"
|
||||||
|
<toast duration="$ToastDuration" scenario="reminder">
|
||||||
|
<visual>
|
||||||
|
<binding template="ToastGeneric">
|
||||||
|
<text>$CustomHello</text>
|
||||||
|
<text>$ToastTitle</text>
|
||||||
|
<text placement="attribution">$Signature</text>
|
||||||
|
<image placement="hero" src="$HeroImage"/>
|
||||||
|
<image placement="appLogoOverride" hint-crop="circle" src="$BadgeImage"/>
|
||||||
|
<group>
|
||||||
|
<subgroup>
|
||||||
|
<text hint-style="title" hint-wrap="true" >$EventTitle</text>
|
||||||
|
</subgroup>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<subgroup>
|
||||||
|
<text hint-style="body" hint-wrap="true" >$EventText</text>
|
||||||
|
</subgroup>
|
||||||
|
</group>
|
||||||
|
</binding>
|
||||||
|
</visual>
|
||||||
|
<audio src="ms-winsoundevent:notification.default"/>
|
||||||
|
<actions>
|
||||||
|
<input id="SnoozeTimer" type="selection" title="Select a Snooze Interval" defaultInput="1">
|
||||||
|
<selection id="1" content="1 Minute"/>
|
||||||
|
<selection id="30" content="30 Minutes"/>
|
||||||
|
<selection id="60" content="1 Hour"/>
|
||||||
|
<selection id="120" content="2 Hours"/>
|
||||||
|
<selection id="240" content="4 Hours"/>
|
||||||
|
</input>
|
||||||
|
<action arguments="$ButtonAction" content="$ButtonTitle" activationType="protocol" />
|
||||||
|
<action activationType="system" arguments="snooze" hint-inputId="SnoozeTimer" content="$SnoozeTitle" id="test-snooze"/>
|
||||||
|
<action arguments="dismiss" content="Dismiss" activationType="system"/>
|
||||||
|
</actions>
|
||||||
|
</toast>
|
||||||
|
"@
|
||||||
|
}
|
||||||
#Prepare XML
|
#Prepare XML
|
||||||
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New()
|
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New()
|
||||||
$ToastXml.LoadXml($ToastTemplate.OuterXml)
|
$ToastXml.LoadXml($ToastTemplate.OuterXml)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue