DECLARE Sleep IN Win32API; INTEGER dwMilliseconds DECLARE INTEGER GetActiveWindow ; IN Win32API DECLARE INTEGER GetWindow IN Win32API ; INTEGER HWND, INTEGER nType DECLARE INTEGER GetWindowText IN Win32API ; INTEGER HWND, STRING @cText, INTEGER nType DECLARE INTEGER BringWindowToTop IN Win32API ; INTEGER HWND Declare integer SetActiveWindow in user32.dll ; integer hwnd oShell = CREATEOBJECT("WScript.Shell") nhandler = 0 *oShell.AppActivate("Calculator") RUN /N CALC.EXE do while nhandler = 0 nhandler = ais_running("Calculator") enddo * is running, so activate it bringwindowtotop(nhandler) oShell.SendKeys("1") = Sleep(200) && Pause VFP for a 1/10 of a second oShell.SendKeys("+") = Sleep(200) && Pause VFP for a 1/10 of a second oShell.SendKeys("2") = Sleep(200) && Pause VFP for a 1/10 of a second oShell.SendKeys("=") = Sleep(200) && Pause VFP for a 1/10 of a second oShell.SendKeys("+") = Sleep(200) && Pause VFP for a 1/10 of a second oShell.SendKeys("3") = Sleep(200) && Pause VFP for a 1/10 of a second oShell.SendKeys("+") = Sleep(200) && Pause VFP for a 1/10 of a second oShell.SendKeys("4") = Sleep(200) && Pause VFP for a 1/10 of a second oShell.SendKeys("=") return FUNCTION ais_running * check if a given application is running LPARAMETER ctitle * hnext = getactivewindow() * iterate through the open windows DO WHILE hnext<>0 ctext = REPLICATE(CHR(0),80) getwindowtext(hnext,@ctext,80) && get window title IF UPPER(ALLTRIM(ctitle)) $ UPPER(ctext) * RETURN hnext ENDIF hnext = getwindow(hnext,2) && next window ENDDO * required window not found RETURN 0 ENDFUNCTIA