Powershell脚本发送键alt选项卡

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

我有一个正在使用Start-Process运行的.exe文件。打开我的应用程序后,我要发送第一个Tab键,然后执行alt + tab。我正在使用以下命令,但到目前为止仅启动了我的应用程序。

Start-Process -FilePath $Exe -WorkingDirectory $Path 
Start-Sleep 10
[System.Windows.Forms.SendKeys]::SendWait(“{TAB}”)
Start-Sleep 2
[System.Windows.Forms.SendKeys]::SendWait(“%{TAB}”)
powershell tabs sendkeys alt
1个回答
0
投票

使用此:

Start-Process -FilePath $Exe -WorkingDirectory $Path 
$wsh = New-Object -ComObject Wscript.Shell 
$wsh.AppActivate("Window title of $exe")
Start-Sleep 10 
$wsh.SendKeys("{TAB}") 
Start-Sleep 2 
$wsh.Sendkeys("%{TAB}")

您需要使用其窗口标题激活exe文件的窗口。还希望使用Wscript.Shell发送密钥。用其窗口标题替换“ $ exe的窗口标题”。

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