【问题标题】:Send keys malfunctions for non English keyboards非英文键盘的发送键故障
【发布时间】:2020-04-10 23:18:46
【问题描述】:

我有以下代码访问特定站点并输入用户名(从 %USERNAME% 获取)。

只要键盘设置为英语,它就可以正常工作,但是,如果键盘设置为另一种语言,它就不能正常工作。

有没有办法从批处理文件中更改键盘输入语言或以其他方式解决此问题?

@if (@CodeSection == @Batch) @then


@echo off

rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
start chrome -new-window --incognito "https://servicedesk.sa.gov.ge/"
rem the script only works if the application in question is the active window. Set a timer to wait for it to load!
timeout /t 3
rem use the tab key to move the cursor to the login and password inputs. Most htmls interact nicely with the tab key being pressed to access quick links.

rem now you can have it send the actual username/password to input box
%SendKeys% "%USERNAME%"
%SendKeys% "{TAB}"

goto :EOF


@end
// JScript section

var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));

【问题讨论】:

  • 我认为很明显,您需要做的是添加一些代码来确定当前用户的键盘语言并相应地进行调整。请不要发布没有表现出特定问题的代码,然后期待有人为您提供解决方案或方法,当您没有表现出自己尝试做这项工作时,他们会继续使用它。你的问题是题外话,因为它是一个直接的代码请求。
  • 实际上非常具体,我提供的代码在键盘是英文的情况下运行良好,当键盘不是英文时出现故障,我只是想弄清楚它的原因和如果有某种简单的解决方案来解决它。
  • 您能告诉我们哪条线路不工作,以便我们帮助您修复它吗?另外,你为什么不像这样使用它? %SendKeys% "%UserName%{TAB}"%SendKeys% "%UserName%{ENTER}"。我问是因为您似乎正在使用您的第一行 sendkeys 仅发送文本字符串,而不是击键!
  • 这是一种更底层的方式winsourcecode.blogspot.com/2019/06/…。请记住,它发送的是 KEYS 而不是字符。
  • 问题在这里 - %SendKeys% "%USERNAME%"。只要输入键盘语言设置为英语,它就可以正常工作,但如果输入语言是其他语言,它会开始输入不同的奇怪符号、字符等。

标签: batch-file keyboard sendkeys


【解决方案1】:

Windows暂时不支持这个功能,我也尝试在超级用户上找到答案,但是还没有现成的解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-02
    • 2014-12-18
    • 2017-08-12
    • 1970-01-01
    • 2012-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多