Share via


ProcessID プロパティ

WshScriptExec オブジェクトによって起動されたプロセスのプロセス ID (PID) です。

Object.ProcessID

引数

  • Object
    WshScriptExec オブジェクトです。

解説

アプリケーションをアクティブにする場合、ProcessID プロパティを (AppActivate メソッドの引数として) 使用します。

使用例

次のコードは、ProcessID プロパティを使って電卓およびメモ帳アプリケーションをアクティブにする例です。

VBScript

Sub delayedSendKeys(str)
     WScript.Sleep 100
     WshShell.SendKeys str
End Sub

Dim WshShell, oCalc, oNotepad
Set WshShell = CreateObject("WScript.Shell")
Set oCalc = WshShell.Exec("calc")
Set oNotepad = WshShell.Exec("notepad")
WScript.Sleep 500

WshShell.AppActivate oCalc.ProcessID
delayedSendKeys "1{+}1~"
delayedSendKeys "^C"
delayedSendKeys "%{F4}"

WshShell.AppActivate oNotepad.ProcessID
delayedSendKeys "1 {+} 1 = ^V"

JScript

function delayedSendKeys(str)
{
     WScript.Sleep(100);
     WshShell.SendKeys(str);
}

var WshShell = new ActiveXObject("WScript.Shell");
var oCalc = WshShell.Exec("calc");
var oNotepad = WshShell.Exec("notepad");
WScript.Sleep(500);

WshShell.AppActivate(oCalc.ProcessID);
delayedSendKeys("1{+}1~");
delayedSendKeys("^C");
delayedSendKeys("%{F4}");

WshShell.AppActivate(oNotepad.ProcessID);
delayedSendKeys("1 {+} 1 = ^V");

参照

WshScriptExec オブジェクト | AppActivate メソッド