Created
April 16, 2021 07:19
-
-
Save o8r/f0ac03637bf5035c97e838748174fa5e to your computer and use it in GitHub Desktop.
Show toast in Windows 10 using Powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <toast> | |
| <visual> | |
| <binding template="ToastGeneric"> | |
| <text>Toast was burnt</text> | |
| <image placement="appLogOverride" src="C:\images\toaster.png"/> | |
| </binding> | |
| </visual> | |
| <actions> | |
| <input id="snoozeTime" type="selection" defaultInput="15"> | |
| <selection id="1" content="1 minute"/> | |
| <selection id="15" content="15 minutes"/> | |
| <selection id="60" content="1 hour"/> | |
| <seloction id="240" content="4 hours"/> | |
| <selection id="1440" content="1 day"/> | |
| </input> | |
| <action activationType="system" arguments="snooze" hint-inputId="snoozeTime" content=""/> | |
| <action activationType="system" arguments="dismiss" content=""/> | |
| </actions> | |
| <audio silent="true"/> | |
| </toast> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Param([string]$clsid, [string]$templateFile) | |
| # Refer Windows Runtime | |
| [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] > $null | |
| [Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null | |
| # Read toast template XML | |
| $template = Get-Content $templateFile | |
| $xml = New-Object Windows.Data.Xml.Dom.XmlDocument | |
| $xml.LoadXml($template) | |
| #Toast notify | |
| $app = $clsid | |
| $toast = New-Object Windows.UI.Notifications.ToastNotification $xml | |
| [Windows.UI.Notifications.ToastNotificationManager]:: CreateToastNotifier($app).Show($toast) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage