我正在尝试使用 WScript Sendkeys 发送字符“ä”。似乎它不起作用。我找到了一个帖子VBscript 的 SendKeys 是否支持 Unicode? https://stackoverflow.com/questions/3198574/does-or-can-vbscripts-sendkeys-support-unicode?rq=1
My Code:
Set sh = WScript.CreateObject("WScript.Shell")
sh.Run "notepad.exe", 9
WScript.Sleep 1000 'wait a while to load notepad app'
sh.SendKeys " äää Hello World!" //buggy line
sh.SendKeys "{ENTER}"
WScript.Sleep 100'
sh.SendKeys "^p"
但我无法理解解决方案。如果您用简单的代码(用于解决方案)教我,那就太好了。我不擅长 WScript(因为这不是我的领域)。
我知道我正在乞求代码(请原谅我)。但请理解我的情况。
提前谢谢了!!
Windows 脚本宿主SendKeys 不支持 Unicode https://stackoverflow.com/a/3215535/113116.
WSH/SendKeys 的替代方案:
-
使用免费工具AutoIt http://www.autoitscript.com/site/autoit/用于 GUI 自动化。您可以使用 AutoItSend https://www.autoitscript.com/autoit3/docs/functions/Send.htm, ControlSend https://www.autoitscript.com/autoit3/docs/functions/ControlSend.htm or ControlSetText https://www.autoitscript.com/autoit3/docs/functions/ControlSetText.htm自动输入文本的命令。
Run('notepad.exe')
WinWaitActive("[CLASS:Notepad]", "", 10)
ControlSend("[CLASS:Notepad]", "", "Edit1", "äää Hello World!")
使用另一种编程语言(C++、C# 等)编写代码并调用 Windows APISendInput http://msdn.microsoft.com/en-us/library/ms646310.aspx函数与KEYEVENTF_UNICODE http://msdn.microsoft.com/en-us/library/ms646271.aspx flag.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)