LoginSignup
18
11

More than 5 years have passed since last update.

Powershellで、実行中の任意のプロセスを呼び出す(備忘録)

Last updated at Posted at 2015-11-20

改良

sample1.ps1
add-type -AssemblyName microsoft.VisualBasic
add-type -AssemblyName System.Windows.Forms
start-sleep -Milliseconds 500

$ps = Get-Process | Where-Object {$_.Name -match "epad"}
foreach($process in $ps){
    [Microsoft.VisualBasic.Interaction]::AppActivate($process.ID);
}

実行中のプロセスから、Notepadを呼び出し、
"1+1="という文字列を送り込む。

これを改良し、タスクバーから、任意のアプリケーションを、
アクティブウィンドウに持ってこれたら、便利かなと思っている。

sample.ps1
add-type -AssemblyName microsoft.VisualBasic
add-type -AssemblyName System.Windows.Forms

Notepad

start-sleep -Milliseconds 500

$ps = Get-Process | Where-Object {$_.Name -eq "Notepad"}

foreach($process in $ps){
    [Microsoft.VisualBasic.Interaction]::AppActivate($process.ID);
    [System.Windows.Forms.SendKeys]::SendWait("1{ADD}1=")
}
18
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
11