你可以用powershell在应用程序之间切换

问题描述 投票:1回答:2

我希望在多个应用程序之间自动轮换,特别是在Kiosk模式下打开的Internet Explorer窗口。这是用于架空显示器。

我已经尝试了文章(how to perform a hold ALT+TAB sendkey event in C#)中的建议,但它对我不起作用。我收到以下错误。

Exception calling "SendWait" with "1" argument(s): "Specified repeat count is not valid."
At line:1 char:35
+ [Windows.Forms.Sendkeys]::SendWait <<<< ("%{Alt Up}")
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

通过手动测试,alt +标签甚至alt +标签+标签只会在前两个/三个窗口之间切换,而我目前有6个可能在未来更多。看起来我可能尝试通过标题拉起窗口,但这似乎不可靠。

#ADD external assemblies here
add-type -AssemblyName microsoft.VisualBasic
add-type -AssemblyName System.Windows.Forms
#Sets interval before changing screens
Start-sleep -Seconds 2
[System.Windows.Forms.SendKeys]::SendWait("%{TAB}%{tab}")
[System.Windows.Forms.SendKeys]::SendWait("%{TAB}%{tab}")

我也试过这个:

[System.Windows.Forms.SendKeys]::SendWait("%{alt down}")
[System.Windows.Forms.SendKeys]::SendWait("%{tab}")
powershell powershell-v2.0
2个回答
1
投票

我想到了。

使用SendWait(“%{TAB}”)

在powershell中,使用alt键的唯一方法似乎是使用%符号。


1
投票

所以我想我明白了。您不希望为切换执行ALT + TAB,因为这是基于Z的交换。这意味着它只在第一个和第二个应用程序运行之间切换。但是,如果您执行Alt + Shift + ESC,这将告诉系统拉出列表中的最后一项并将其前移

© www.soinside.com 2019 - 2024. All rights reserved.