如何在VBScript中使用“Alt + tab”快捷键?

5
set test = CreateObject("WScript.Shell")
test.SendKeys"%{TAB}"
WScript.Sleep 500

第二行的快捷命令无法使用!有人能帮我吗?

如果你想的话,这段代码可以在一行中运行:set test =createobject("wscript.shell"):wscript.sleep 500:test.sendkeys"%{TAB}":wscript.echo "Done" - Hackoo
5个回答

3
Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")

WshShell.SendKeys "^%{TAB}"

Set WSHShell = Nothing

WScript.Quit(0)

3

当您通过批处理文件或CMD运行VBScript时,

一个选项卡将带您回到运行脚本之前的位置

您可能会认为没有任何反应。

尝试使用alt + TAB + TAB

或者更多的选项卡

set test = CreateObject("WScript.Shell") test.SendKeys"%({TAB}{TAB})" WScript.Sleep 500


1

WshShell.SendKeys "^%{TAB}" Works for me.


0

要快速在最近使用的应用程序之间切换,请使用:

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "%^{TAB}"
WScript.Sleep 45
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}" 

并使用记事本保存为appswitch.vbs。


-2

在尝试了这里提到的各种方法后,我想出了一些似乎有效的东西。

set wsh = CreateObject("wscript.shell")
wsh.SendKeys "^%({TAB}{TAB})"
wscript.sleep 100
wsh.SendKeys "{ENTER}"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接