|
AppActivate Method |
|
Description
Activates an application window.
PowerBASIC Syntax
Arguments
Remarks
The AppActivate method returns a Boolean value that identifies whether the procedure call is successful. This method changes the focus to the named application or window, but it does not affect whether it is maximized or minimized. Focus moves from the activated application window when the user takes action to change the focus (or closes the window).
In determining which application to activate, the specified 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 cannot be 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 [PowerBASIC]
The following example demonstrates the use of the SendKeys method. It runs the Windows calculator and sends it keystrokes to execute a simple calculation.
#INCLUDE "WSHOM.INC"
DIM pWsh AS IWshShell2 DIM lExitCode AS LONG DIM vApp AS VARIANT
pWsh = NEWCOM "WScript.Shell" lExitCode = pWsh.Run(UCODE$("calc")) SLEEP 100 vApp = "Calculator" pWsh.AppActivate vApp SLEEP 100 pWsh.SendKeys UCODE$("1{+}") SLEEP 500 pWsh.SendKeys UCODE$("2") SLEEP 500 pWsh.SendKeys UCODE$("~") SLEEP 500 pWsh.SendKeys UCODE$("*3") SLEEP 500 pWsh.SendKeys UCODE$("~") SLEEP 2500
|
