windows VBScript 发送键 CTRL+LWIN+TAB?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12877547/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:58:37  来源:igfitidea点击:

VBScript SendKeys CTRL+LWIN+TAB?

windowsvbscriptsendkeyskeystroke

提问by daniel11

I am trying to write a simple script that will send the key combo of CTRL+WINDOWS KEY+TAB. The code below sends the keys CTRL+ALT+TAB

我正在尝试编写一个简单的脚本来发送CTRL+ WINDOWS KEY+的键组合TAB。下面的代码发送键CTRL+ ALT+TAB

Set WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.SendKeys "^%{TAB}"

However when I try to replace "%" (aka the ALTkey) with LWIN(aka the Left Windows Key) it says Syntax Error.

但是,当我尝试ALTLWIN(又名左 Windows 键)替换“%”(又名键)时,它说语法错误。

I tried the following, but had no luck:

我尝试了以下方法,但没有运气:

Set WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.SendKeys "^{LWIN}{TAB}"

 

 

Set WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.SendKeys "^{LWIN}+{TAB}"

 

 

Set WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.SendKeys ^{LWIN}+{TAB}

I know it has something to do with being able to Hold certain keys while other keys are pressed but I can't seem to get it right.

我知道这与能够在按下其他键时按住某些键有关,但我似乎无法正确使用。

The windows key can be pressed programmatically using CTRL+ESC. Is there a way to set this combination as a variable called LWINand then use one of the above Scripts?

可以使用CTRL+以编程方式按下 windows 键ESC。有没有办法将此组合设置为调用的变量LWIN,然后使用上述脚本之一?

采纳答案by gmo

Just in case someone land here on these years...
A workaround (instead of sending keystrokes) is to call directly to the application:

以防万一有人在这些年登陆......
一种解决方法(而不是发送击键)是直接调用应用程序:

Set objShell = CreateObject("Shell.Application")
objShell.WindowSwitcher

This will open Task SwitcherWindows App. (Same as ? windows+TAB)

这将打开Task SwitcherWindows 应用程序。(同? windows+ TAB

回答by Robin

try this code:

试试这个代码:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "+(^{LWIN}{TAB})"

回答by RLH

I know you are looking for VBscript but it looks like that is unlikely (pure VBscript). Here is a post that did solve this via C#.

我知道您正在寻找 VBscript,但看起来不太可能(纯 VBscript)。这是一篇通过 C# 解决此问题的帖子。

https://stackoverflow.com/a/10367832/1742115

https://stackoverflow.com/a/10367832/1742115

This pagetells how to call the C# DLL from your VBscript if you want to keep some of this in vbs.

如果您想在 vbs 中保留其中的一些内容,此页面将介绍如何从您的 VBscript 调用 C# DLL。

回答by Helen

I think your question is an example of an XY problemand what you actually want to do is to activate Flip 3D (Switch between windows). You can do this programmatically by executing the rundll32 DwmApi #105command:

我认为您的问题是XY 问题的一个示例,您实际上想要做的是激活 Flip 3D(在窗口之间切换)。您可以通过执行以下rundll32 DwmApi #105命令以编程方式执行此操作:

CreateObject("WScript.Shell").Run "rundll32 DwmApi #105"