CTRL+1 不起作用 [英] CTRL+1 is not working

查看:83
本文介绍了CTRL+1 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Option Explicit

Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run """C:\Program Files (x86)\Blackmagic Design\Blackmagic Media Express\MediaExpress.exe""" ,1,true

Wscript.Sleep 100
WshShell.SendKeys "^1"

Set WshShell = Nothing

推荐答案

.SendKeys 方法使用字母数字键盘来传输数字.我的键盘(最上面的 EscF1... 键行下的数字行)行为如下(使用捷克语键盘输入):

.SendKeys method uses alphanumeric keypad for transmitting digits. My keyboard (the line with numbers under the uppermost EscF1 key row) behaves as follows (using Czech keyboard input):

°1234567890 带有 Shift

;+ĚŠČŘŽÝÁÍÉ 带有 CapsLock

;+ěščřžýáíé 未修改

我可以确认例如WshShell.SendKeys "^1"(使用 Windows Script Host Version 5.8)发送 Ctrl+Shift+1 键击活动窗口,就像在键盘上键入一样.

I can confirm that e.g. WshShell.SendKeys "^1" (with Windows Script Host Version 5.8) sends Ctrl+Shift+1 keystrokes to the active window as if typed on the keyboard.

我的回答:我需要使用 WshShell.SendKeys "^{+}" 来模拟键盘 Ctrl+1 输入.

My answer: I need to use WshShell.SendKeys "^{+}" to emulate keyboard Ctrl+1 input.

.SendKeys 的行为独立 调用 cmd 窗口中的当前键盘布局(输入法)(cscript//nologo 34189495.vbs) 并在 WshShell.SendKeys "^1" 之前激活的窗口中.测试了
所有组合- Windows 显示语言 English (UK),键盘输入法 Czech/United Kingdom
- 显示语言Czech,键盘输入法Czech/US-international,
互相对抗……

Above .SendKeys behaviour is independent on current keyboard layout (input method) in calling cmd window (cscript //nologo 34189495.vbs) and in window activated right before WshShell.SendKeys "^1". Tested all combinations of
- Windows display language English (UK), keyboard input method Czech/United Kingdom and
- display language Czech, keyboard input method Czech/US-international,
each versus each other…

另一个问题:如何使用.SendKeys模拟键盘输入Ctrl+2代码>方法?我不能简单地使用 WshShell.SendKeys "^{ě}".它不起作用,因为ě(带有caron的拉丁小写字母E)十六进制值大于0x79(和ščřžýáíé 还有).根据 键盘扫描代码规范 Microsoft 文档,前缀扫描代码部分(抱歉提供下载链接):

Another problem: how to emulate keyboard input Ctrl+2 using .SendKeys method? I can't use simply WshShell.SendKeys "^{ě}". It does not work because ě (latin small letter E with caron) hexadecimal value is greater than 0x79 (and ščřžýáíé as well). As per Keyboard Scan Code Specification Microsoft document, Prefixed Scan Codes part (sorry for link to download):

如果您使用 0xE0 集合中的扫描码,请确保第二个字节以与单字节扫描码值相同的方式适用.其他词:不大于0x79,不0x600x61,不0x00...

If you use scan codes from the 0xE0 set, make sure the second byte is suitable in the same way as single byte scan code values. In other words: Not greater than 0x79, Not 0x60 or 0x61, Not 0x00

但是,这里有一个解决方法:WshShell.SendKeys "{NUMLOCK}^{ě}{NUMLOCK}"(谁知道它为什么会起作用?源自我以前使用keyboard wedge 的经验条码扫描仪!)

However, here is a workaround: WshShell.SendKeys "{NUMLOCK}^{ě}{NUMLOCK}" (who knows why it works? Derived from my previous experience with keyboard wedge barcode scanners!)

附录:使用我首选的文本和代码编辑器 PSPad 进行测试;

Addendum: tested using my preferred text and code editor PSPad;

这是我的工作代码:

option explicit
'On Error Resume Next
On Error GoTo 0
Dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
' WshShell.Run omitted, activate existing window (this script open in PSPad)
WScript.Sleep 100
WshShell.AppActivate "34189495.vbs"
WScript.Sleep 200
' Ctrl+Shift+3 set marker #3
WshShell.SendKeys "^3"
WScript.Sleep 100
' Ctrl+1 goto marker #1, i.e. move cursor to that line (pre)marked 1 
WshShell.SendKeys "^{+}"
' more time to observe 
WScript.Sleep 3000
' Ctrl+3 goto marker #3, i.e. move cursor to that line marked 3 
WshShell.SendKeys "{NUMLOCK}^{Š}{NUMLOCK}"
WScript.Sleep 100
' more time before quit
WScript.Sleep 3000
Wscript.Echo Wscript.ScriptName
Wscript.Quit

这篇关于CTRL+1 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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