-
-
Save GitHub30/e8024db733090d921cab46f2ed4bdd79 to your computer and use it in GitHub Desktop.
Example of trying to register a Windows RT event via PowerShell, specifically here we're looking at events on Toast Notifications
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
$XmlString = @" | |
<toast> | |
<visual> | |
<binding template="ToastGeneric"> | |
<text>Default Notification</text> | |
<image src="C:\Windows\IdentityCRL\WLive48x48.png" placement="appLogoOverride" /> | |
</binding> | |
</visual> | |
<audio src="ms-winsoundevent:Notification.Default" /> | |
</toast> | |
"@ | |
$AppId = 'Microsoft.AutoGenerated.{A49227EA-5AF0-D494-A3F1-0918A278ED71}' | |
$null = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | |
$null = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | |
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::new() | |
$ToastXml.LoadXml($XmlString) | |
$Toast = [Windows.UI.Notifications.ToastNotification]::new($ToastXml) | |
$Toast | Get-Member -MemberType Event | |
Register-ObjectEvent -InputObject $Toast -EventName Activated -Action { | |
Out-File -FilePath C:\Temp\Event.txt -InputObject (Get-Date -Format 'o') -Append -Force | |
} | |
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($AppId).Show($Toast) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment