如何让PowerShell的BurntToast Toast通知保持至用户操作?
让BurntToast通知保持显示直至用户关闭的方法
要让你的PowerShell Toast通知保持显示直到用户手动关闭,只需在New-BurntToastNotification命令中添加-Scenario参数,指定Reminder或IncomingCall场景即可——这两个Windows原生的通知场景会强制通知常驻,不会自动消失。
修改后的完整脚本如下:
Import-Module BurntToast $button = New-BTButton -Dismiss -Content "OK" New-BurntToastNotification -Text 'Yoooo, this is a toast notification... from PowerShell!' -Button $button -Scenario "Reminder"
说明
Reminder场景:通知会持续显示在屏幕右下角,直到用户点击"OK"按钮或手动关闭通知,适合需要用户确认的提示。IncomingCall场景:效果与Reminder类似,但通知样式更醒目,适合需要用户立即关注的场景。
这两个场景都是利用Windows Toast通知的原生特性,BurntToast模块只是对其进行了封装调用,无需额外配置即可生效。
内容的提问来源于stack exchange,提问作者Arbelac
相关产品推荐
相关产品推荐

