1

多くのアプリケーションには、F1キーを押して呼び出すヘルプが関連付けられています。
どのPowerShellコマンドでアプリケーションを起動し、ヘルプを開きますか?
私が考えているアプリケーションは、Powershell ISE、Visual Studio、Microsoft Officeなど
です。これに標準的なメカニズムはありますか?

ありがとう。

4

1 に答える 1

2

それを実行するコマンドは1つではありませんが、次の方法で実行できます。

  1. アプリケーションを起動します。
  2. ウィンドウをアクティブにする
  3. F1キーを送信します。

方法は次のとおりです。

アプリケーションを起動します。

Start-Process -FilePath C:\The\Path\To\Program.exe 

それを待つ:

$WindowTitle = "The App You're Waiting For"
while ($true) {
    Start-Sleep -Seconds 1
    $p = get-process | ? {$_.MainWindowTitle -match $WindowTitle}
    if ($p) {break}
}

ウィンドウをアクティブにします。

[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic")
[Microsoft.VisualBasic.Interaction]::AppActivate($WindowTitle)

F1キーを送信します。

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.SendKeys]::SendWait("{F1}")
于 2012-02-29T06:36:57.583 に答える