我已经使用Powershell脚本创建并显示带有“已确认”按钮的Windows Toast通知。我想等到用户单击Toast按钮,然后再继续执行脚本的其余部分。
$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
$Template = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText04
$Title = "Message "
$Text1 = "You need to click that button below..."
$Text2 = "...click on Acknowledged."
[xml]$ToastTemplate = ([Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($Template).GetXml())
[xml]$ToastTemplate = @"
<toast scenario="reminder" launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text hint-style="title">$Title</text>
<group>
<subgroup>
<text hint-style="body" hint-wrap="true" >$Text1</text>
</subgroup>
</group>
<group>
<subgroup>
<text hint-style="body" hint-wrap="true" >$Text2</text>
</subgroup>
</group>
</binding>
</visual>
<actions>
<action activationType="foreground" content="Acknowledged" arguments="OK" />
</actions>
</toast>
"@
$ToastXml = New-Object -TypeName Windows.Data.Xml.Dom.XmlDocument
$ToastXml.LoadXml($ToastTemplate.OuterXml)
$notify = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app)
$notify.Show($ToastXml)
Write-Host "The rest of the code that executes only AFTER user click the button..."