Powershell:如果用户在Toast-Message中按下按钮,则继续脚本

问题描述

如果用户通过Toast-Message中的“是”按钮确认(我在此项目中不选择使用Windows.Forms),则我正在寻找继续Powershell脚本的选项。 我该怎么办?

这是我到目前为止的示例代码:

$null = [Windows.UI.Notifications.ToastNotificationManager,Windows.UI.Notifications,ContentType = WindowsRuntime]
$null = [Windows.Data.Xml.Dom.XmlDocument,Windows.Data.Xml.Dom.XmlDocument,ContentType = WindowsRuntime]

$XmlString = @"
  <toast launch = "Test1" scenario='alarm'>
    <visual>
      <binding template="ToastGeneric">
        <text>Title</text>
        <text>Message</text>
      </binding>
    </visual>
    <audio src="ms-winsoundevent:Notification.Looping.Alarm" />
    <actions>
        <action content="yes" arguments="yes" activationType="foreground" />
        <action content="no" arguments="no" activationType="foreground" />
    </actions>
  </toast>
"@

$AppId = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::new()
$ToastXml.LoadXml($XmlString)
$Toast = [Windows.UI.Notifications.ToastNotification]::new($ToastXml)
$null  = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($AppId).Show($Toast)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)