VBS - 带花括号的发送键

问题描述

我正在尝试升级在其高级脚本部分使用 VBS 的 Dragon Speech Recognition。虽然使用 SendKeys 的行为很奇怪。我想发送花括号:

SendKeys "{}}"

抛出错误,同时

SendKeys "^%0"

完美运行。即使 SendKeys "{{}" 也能工作,但右花括号只能通过 Shift + Alt + 0 完成。

分别使用 documentation clearly states {{}{}} 但这不起作用。我在这里遗漏了什么吗?

解决方法

作为 suggested in the comments,您需要在 Dragon Speech Recognition 的范围之外对此进行测试。我这样说是因为,通过一个简单的测试,很明显 SendKeys 的行为符合预期。

Dim shell: Set shell = WScript.CreateObject("WScript.Shell")
Call shell.Run("notepad")
Call WScript.Sleep(100)
Call shell.AppActivate("Notepad")
Call shell.SendKeys("{{}")
Call WScript.Sleep(100)
Call shell.SendKeys("{}}")

输出(在记事本中):

{}