Microsoft® Windows® Script Host
AppActivate Method
WSH Reference
Version 2

Applies To


Description
Activates an application window.
Syntax
AppActivate title
Parameters
Part Description
title Required. String expression specifying the title in the title bar of the application window that you want to activate. You can use the task ID returned by the Shell function in place of title to activate an application.
Remarks

The AppActivate statement changes the focus to the named application or window but does not affect whether it is maximized or minimized. Focus moves from the activated application window when the user takes some action to change the focus or closes the window. Use the Shell function to start an application and set the window style.
In determining which application to activate, title is compared to the title string of each running application. If no exact match exists, any application whose title string begins with "title" is activated. If an application still is not found, any application whose title string ends with title is activated. If more than one instance of the application named by title exists, one instance is arbitrarily activated.

Example
The following example starts the Windows calculator and performs some simple calculations.
set WshShell = CreateObject("WScript.Shell")
WshShell.Run "calc"
WScript.Sleep 100
WshShell.AppActivate "Calculator"
WScript.Sleep 100
WshShell.SendKeys "1{+}"
WScript.Sleep 500
WshShell.SendKeys "2"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 500
WshShell.SendKeys "*3"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 2500