Example - AppActivate Statement

Dim WshShell As Object 'Set WshShell As Global Object
Sub Main()
   Dim n
   n = 5
   Set WshShell = CreateObject("WScript.Shell")
   WshShell.Run "calc.exe"
   WshShell.AppActivate "Calculator"
   Wait 5 ' Wait For some time To bring focus On application
   For I = 1 To (n-1) ' Set up counting Loop.
      WshShell.SendKeys I & "{+}" ' Send keystrokes To Calculator
   Next I ' To add Each value of I.
   WshShell.SendKeys "{+}" & n & "=" ' Get grand total.
End Sub
 
Private Sub Wait(ByVal nSec As Long)
   nSec = nSec + Timer
   While nSec > Timer
      'Timer running...
   Wend
End Sub