Customising Toast XML to use selectbox items and run custom protocols

Aleksander Nowak 1 Reputation point
2023-01-05T11:10:36.71+00:00

Hi,

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

$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 = "http://google.com/"  
$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">  
    <visual>  
        <binding template="ToastGeneric">  
            <text>$CustomHello</text>  
            <text>$ToastTitle</text>  
            <text placement="attribution">$Signature</text>  
            <image placement="hero" src="$BannerImage"/>  
            <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>  
     <actions>  
        <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:"/>  
        </input>  
        <action activationType="protocol" arguments="WHAT DO I PUT HERE" hint-inputId="MySelection" content="RUN"/>  
        <action arguments="dismiss" content="" activationType="system"/>  
    </actions>  
</toast>  
"@  
  
  
#Prepare XML  
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New()  
$ToastXml.LoadXml($ToastTemplate.OuterXml)  
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)  
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($LauncherID)  
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,601 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.