WScript Sendkey 不接受 Unicode 字符 [英] WScript Sendkey doesn't accept Unicode Characters

查看:41
本文介绍了WScript Sendkey 不接受 Unicode 字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 WScript Sendkeys 发送字符ä".似乎它不起作用.我找到了一篇文章 VBscript 的 SendKeys 是否支持 Unicode?

I am trying to send char "ä" using WScript Sendkeys.Seems its not working . I found one post 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(因为它不是我的领域).我知道我在乞求代码(请原谅我).但请理解我的情况.

but i am unable to understand the solution. Would be great if you teach me in plain simple code (for solution). I am not good at WScript(as its not my area). I know i am begging for code(Pz forgive me). but plz understand my situation.

非常感谢!

推荐答案

Windows Script Host 的 SendKeys 不支持 Unicode.

Windows Script Host's SendKeys doesn't support Unicode.

WSH/SendKeys 的替代方案:

Alternatives to WSH/SendKeys:

  • Use the free tool AutoIt for GUI automation. You can use AutoIt's Send, ControlSend or ControlSetText commands to automate text input.

Run('notepad.exe')
WinWaitActive("[CLASS:Notepad]", "", 10)
ControlSend("[CLASS:Notepad]", "", "Edit1", "äää Hello World!")

  • 用另一种编程语言(C++、C# 等)编写代码并调用 Windows API SendInput 函数与 KEYEVENTF_UNICODE 标志.

    这篇关于WScript Sendkey 不接受 Unicode 字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆