The process ID (PID) for a process started with the WshScriptExec object.
Parameters
- Object
WshScriptExec object.
Remarks
Example
The following code uses the ProcessID property to activate the calculator and notepad applications.
Visual Basic Script | Copy Code |
---|
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 | Copy Code |
---|
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"); |
See Also