Run custom protocol based on selection box in windows toast notification

Microsoft Windows
Post Reply
Posts: 1
Joined: 2023-Jan-04, 1:35 pm

Run custom protocol based on selection box in windows toast notification

Post by nawadsama »

HI all,

I have previosly created a script that launches custom toast notification with buttons launching scripts via custom Classes/Protocols. Now i wanted to make it prettier and included a SelectionBox. I am unable to run those custom protocols based on Selected item. Please advise

Code: Select all

$ToastTitle = ""
$Signature = ""
$BannerImage = 'C:\Users\anowak\OneDrive - Phlexglobal Ltd\Desktop\Personal\Scripts\Toast\lake.jpg'
$EventTitle = "Testing Title"
$EventText = "This is where there would normally be info. This is just a test though."
$site = ""
$MoreInfoTitle = "More Information"
$Snooze = $true
$CustomHello = "Hello $env:USERNAME"

#Specify Launcher App ID, the App that will claim ownership of the toast notification, doesn't affect functionality.
$LauncherID = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'

#Load Assemblies
[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
#Build XML Template
[xml]$toastTemplate = @"
<toast duration="long" scenario="reminder">
        <binding template="ToastGeneric">
            <text placement="attribution">$Signature</text>
            <image placement="hero" src="$BannerImage"/>
                    <text hint-style="title" hint-wrap="true" >$EventTitle</text>
                    <text hint-style="body" hint-wrap="true" >$EventText</text>
        <input id="MySelection" type="selection" title="Choose:" defaultInput="1">
            <selection id="1" content="Zenek:"/>
            <selection id="2" content="NetExt"/>
            <selection id="3" content="Shorts"/>
            <selection id="4" content="Busy"/>
            <selection id="5" content="Time"/>
        <action activationType="protocol" arguments="WHAT DO I PUT HERE" hint-inputId="MySelection" content="RUN"/>
        <action arguments="dismiss" content="" activationType="system"/>

#Prepare XML
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New()
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
Post Reply