vba - Powershell Wscript.Shell 弹出窗口超时不超时
问题描述
我正在使用$wshell.Popup($time, $time, 'Warning', 48 + 4096)
一个超时的弹出窗口。当我编写超时时间为 5 的代码时,一切都运行良好,但是当我投入生产时,它以较长的超时时间工作失败。所以我写了下面的代码来说明奇怪的行为。超过 19 秒的值在我的计算机上不起作用。有没有人遇到同样的问题?如何解决这个问题?
(我有 PSVersion:5.1.18362.1171 & VBScript.5.8.16384)
$time = 1
$increment = 1
$Exclamation = 48
$ShowOnTop = 4096
$wshell = New-Object -ComObject Wscript.Shell
while($true){
$start = get-date
$null = $wshell.Popup($time, $time, 'Warning', $Exclamation + $ShowOnTop)
$delta = (get-date) - $start
write-host "pop up $time took $($delta.TotalSeconds)" -ForegroundColor Green
$time += $increment
}
输出:
pop up 1 took 1.1034666
pop up 2 took 2.1012811
pop up 3 took 3.1027432
pop up 4 took 4.1011674
pop up 5 took 8.8805263
pop up 6 took 6.1285214
pop up 7 took 13.8968735
pop up 8 took 8.1029593
pop up 9 took 11.9174401
pop up 10 took 19.0161058
pop up 11 took 19.0150746
pop up 12 took 19.0156603
pop up 13 took 19.0159296
pop up 14 took 19.030777
pop up 15 took 19.0175581
pop up 16 took 19.0388007
pop up 17 took 19.0392871
pop up 18 took 19.043456
pop up 19 did not end after 270 seconds...
作为隔离问题的测试,我创建了这个 vbs 文件。30秒后成功超时:
CreateObject("WScript.Shell").Popup "Hello!", 30, "Title", 4144
解决方案
推荐阅读
- javascript - 如何更改三角形每一侧的图像(任何纹理)?
- c++ - 如何有效地计算每个多边形区域内的所有非零像素?
- go - 当显然不是时,切片超出范围
- reactjs - 字体在每页的每次刷新时执行 FOUT(无样式文本的 Flash)
- spring - 使用 Spring R2DBC 存储库时,我可以提供自己的自定义 R2dbcEntityTemplate 吗?
- javascript - 'React' 指的是一个 UMD 全局,但当前文件是一个模块
- ms-access - 有没有办法让 Access 通过查询成为 SQL 服务器初始登录的一部分?
- django - Django - 如何使用 ForeignKey 的存在作为条件来设置模型的字段?
- gitlab - 我们可以从 Gitlab CI 获取消息吗?
- node.js - Node.js 将字符串加密为字母数字