unicode - WScript Sendkey 不接受 Unicode 字符

标签 unicode vbscript sendkeys wsh

我正在尝试使用 WScript Sendkeys 发送字符“ä”。它似乎不起作用。我找到一个帖子 Does or Can VBscript's SendKeys support Unicode?

我的代码:

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 doesn't support Unicode .

WSH/SendKeys 的替代品:

  • 使用免费工具 AutoIt用于 GUI 自动化。您可以使用 AutoIt 的 Send , ControlSendControlSetText自动文本输入的命令。

    Run('notepad.exe')
    WinWaitActive("[CLASS:Notepad]", "", 10)
    ControlSend("[CLASS:Notepad]", "", "Edit1", "äää Hello World!")
    
  • 用另一种编程语言(C++、C# 等)编写代码并调用 Windows API SendInput功能与KEYEVENTF_UNICODE旗帜。

关于unicode - WScript Sendkey 不接受 Unicode 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23058634/

相关文章:

file - vbs所有用户桌面文件夹

sql-server-2005 - 如何将亚美尼亚语字符串插入 SQL Server 数据库

ruby - 转换已经用 UTF-8 编码的 ruby​​ 字符串中的 unicode 字符

java - 从 jdbc/SQL Server 2005 读取希腊文本并用 servlet 显示它

vbscript - 你能在 VBScript 中声明一个常量数组吗?

c# - 如何将 Hex 转换为 Unicode?

VBscript 相对路径

selenium - Selenium webdriver上的SendKeys偶尔在Internet Explorer 10中以大写形式发送文本

python - 属性错误: 'selenium' object has no attribute 'send_keys' with Selenium and Python