Подождите, пока пользователь не отклонит сообщение Toast - PullRequest
0 голосов
/ 26 апреля 2019

Я создал и отобразил Windows Toast Notification с кнопкой «Подтверждено» с помощью скрипта Powershell. Я хотел бы подождать, пока пользователь не нажмет кнопку 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..."

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...