Skip to content

Instantly share code, notes, and snippets.

@Windos
Created February 7, 2019 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Windos/7c750e9252bef7b654fb8464b0bcc708 to your computer and use it in GitHub Desktop.
Save Windos/7c750e9252bef7b654fb8464b0bcc708 to your computer and use it in GitHub Desktop.
Import-Module BurntToast
$Text1 = New-BTText -Content 'This is a test'
$Text2 = New-BTText -Content 'This more testing'
$AppLogo = New-BTImage -Source 'https://raw.githubusercontent.com/Windos/BurntToast/master/Media/BurntToast.png' -Crop Circle -AppLogoOverride
$Binding1 = New-BTBinding -Children $Text1, $Text2 -AppLogoOverride $AppLogo
$Visual1 = New-BTVisual -BindingGeneric $Binding1
$Content = New-BTContent -Visual $Visual1
$AppId = "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe"
$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()
$CleanContent = $Content.GetContent().Replace('<text>{', '<text>')
$CleanContent = $CleanContent.Replace('}</text>', '</text>')
$CleanContent = $CleanContent.Replace('="{', '="')
$CleanContent = $CleanContent.Replace('}" ', '" ')
$ToastXml.LoadXml($CleanContent)
$Toast = [Windows.UI.Notifications.ToastNotification]::new($ToastXml)
Register-ObjectEvent -InputObject $Toast -EventName 'Activated' -Action {Write-Warning 'WORKING!'}
[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