*Procedure yPushWindow lParameter pWindowTitle, pSendKeys, pnTimeOut, pnCheckInterval if version(2)=0 _screen.left=-5000 endif do case case type("pnCheckInterval")="N" case type("pnCheckInterval")="C" and isdigit(pnCheckInterval) pnCheckInterval=val(pnCheckInterval) case type("pnTimeOut")="C" and " "$ALLTRIM(pnTimeOut) pnCheckInterval=val(; SUBSTR(ALLTRIM(pnTimeOut),rAT(" ",ALLTRIM(pnTimeout))+1)) otherwise pnCheckInterval=1000 && 1 sec endcase do case case type("pnTimeOut")="N" case type("pnTimeOut")="C" and isdigit(pnTimeOut) pnTimeOut=val(pnTimeOut) otherwise pnTimeOut=60000 && 1 min endcase IF TYPE("pSendKeys") #"C" pSendKeys="{ENTER}" ENDIF IF TYPE("pWindowTitle") #"C" pWindowTitle="Window Title" ENDIF PRIVATE oShell, LtimerOL, Starttime starttime=SECONDS() oShell = CreateObject("WScript.Shell") LtimerOL=createobject("PushWindow",pWindowTitle, pSendKeys,; pnTimeOut,pnCheckInterval) read events LtimerOL=.NUll. oShell=.Null. Return *---------------------------------------- Define class PushWindow as Timer Interval = 1000 Name = "PushWindow" timeoutdef = 60000 WindowTitle = "Command Prompt" SendKeys = "exit{ENTER}" Procedure INIT Lparameter pWindowTitle, pSendKeys, pnTimeOut, pInterval if type("pWindowTitle")="C" AND NOT EMPTY(pWindowTitle) this.WindowTitle=pWindowTitle endif if type("pSendKeys")="C" AND NOT EMPTY(pSendKeys) this.SendKeys=pSendKeys this.SendKeys=pSendKeys endif if type("pnTimeOut")="N" this.timeoutdef=pnTimeOut endif if type("pInterval")="N" this.Interval=pInterval ENDIF endproc Procedure Timer WAIT wind NOWAIT "Looking for Window Title "+this.WindowTitle if oShell.AppActivate(this.WindowTitle) oShell.SendKeys(this.SendKeys) ENDIF IF SECONDS()-starttime>=this.timeoutdef/1000 clear events ENDIF Endproc Enddefine2. Example of Main application calling the utility above:
CLEAR lcText="Plain Text - simple assign and retrieve, wrongword goes here" LOCAL loWord as Word.Application loWord = CREATEOBJECT("Word.Application") loWord.Visible = .t. = loWord.Documents.Add(,,1,.T.) * call the timer, and accept ALL recommended spellings (ALT+l) oShell = CreateObject("WScript.Shell") oShell.Run([c:\ypushwindow "Spelling: " "%l" 3000]) WITH loWord.activedocument .Content.Text = lcText .CheckSpelling() lcText1 = .Content.Text ?lcText && original text ?lcText1 && correct spelling ENDWITH loWord.Quit(.f.) loWord = .null. oShell=.null.Regards