SendKeys Function

 

SendKeys (Keys, [wait])

 

Sends one or more keystrokes to the active window as if they had been entered at the keyboard

 

The SendKeys statement has two parameters.   The first parameter keys is a string and is sent to the active window.  The second parameter wait is optional and if omitted is assumed to be false.  If wait is true the keystrokes must be processed before control is returned to the calling procedure.

 

Example:

 

Sub Main ()

   Dim I, X, Msg ' Declare variables.

   X = Shell("Calc.exe", 1)   ' Shell Calculator.

   For I = 1 To 5   ' Set up counting loop.

       SendKeys I & "{+}", True   ' Send keystrokes to Calculator

   Next I ' to add each value of I.

   AppActivate "Calculator"   ' Return focus to Calculator.

   SendKeys "%{F4}", True  ' Alt+F4 to close Calculator.

End Sub