3telnick Posted June 1, 2006 Author Share Posted June 1, 2006 (edited) Script failed to start due to console blocking screensaver :"> Now the last (i hope) problem - due to heavy load of the computer early in the morning script still hangs after few loops (still the same old story WinWaitActive)... It is something time dependent, but I cannot figure out precisely what exactly it is Edited June 1, 2006 by 3telnick Link to comment Share on other sites More sharing options...
3telnick Posted June 8, 2006 Author Share Posted June 8, 2006 (edited) Ok. The ultimate solution is (I cross my fingers for it) to exchange WinMenuSelectItem with Send ({ALTDOWN}key) sequence (if possible). That works much more better in my case Edited June 8, 2006 by 3telnick Link to comment Share on other sites More sharing options...
3telnick Posted August 23, 2006 Author Share Posted August 23, 2006 Nope, it still fails to open menu (sometimes). When computer which is running script is loaded and responses are slower menu is never activated, neither using Send (Alt+Key) combination nor WinMenuSelectItem... Script hangs because it waits till menu is active. It's enough to manually open menu option and script resumes working for a several loops. Sometimes it happens, sometimes not. I cannot tell what to do to make it work properly... Link to comment Share on other sites More sharing options...
MHz Posted August 23, 2006 Share Posted August 23, 2006 (edited) While 1 $file = FileFindNextFile($search) If @error Then ExitLoop ;only for those starting with "#" If StringLeft($file,1)="#" Then ;run report WinWaitActive("Impromptu","") If Not WinActive("Impromptu","") Then WinWaitActive("Impromptu","") WinWaitActive("Impromptu","") WinMenuSelectItem("Impromptu", "", "&Report", "&Prompt..." ) ;check "Prompts" window WinWait("Prompts","") If Not WinActive("Prompts","") Then WinWaitActive("Prompts", "") WinWaitActive("Prompts","") ;send params Send(StringRight($file,4) & "{ENTER}") See that Active bolded in your last post of code. I would believe if you remove the bold Active part of the function name, then it may not fail as easy. Remove the following 2 lines, and I would consider to run much better. To my knowledge, WinMenuSelectItem does not require an active window. This runs Notepad looping. If I set that up with an endless loop, then I would expect it to run all day without failing for it's own issue unless Notepad crashes or the messages sent get messed up with windows or some other OS breakdown or maybe the script may fault. The script is only as good as I make it to be. For $i = 1 To 10 Run('Notepad') ; Just WinWait() for using WinMenuSelectItem() If WinWait('Untitled', '', 5) Then WinMenuSelectItem('Untitled', '', '&File', 'Save &As...') ; ; Use WinWaitActive() for Send() If WinWait('Save As', '', 5) Then While WinExists('Untitled') And WinExists('Save As') And Not WinActive('Save As') WinActivate('Save As') Sleep(250) WEnd If WinWaitActive('Save As', '', 5) Then Send('some text') EndIf EndIf ; Sleep(1000) WinClose('Save As') WinKill('Untitled') Sleep(500) EndIf Next Edit: Look at the WinWaitActive in bold also as that should be WinActivate. Edited August 23, 2006 by MHz Link to comment Share on other sites More sharing options...
3telnick Posted August 23, 2006 Author Share Posted August 23, 2006 (edited) Thanks for new idea but it still doesn't work. I've changed loop to make it once only. Program runs, then opens menu "Prompt" and generates report with particular prompt (here: RPOA). In about 50% of cases script waits till time out on If WinWait("Save As", "", 5) Then statement. In about another 50% of cases it opens menu "Save As...", writes results and ends. Any idea where to kick to make it work? expandcollapse popupFor $i = 1 To 1 Run("E:\Program Files\Cognos\cer4\bin\impadmin.exe", "e:\Program Files\Cognos\cer4\bin\", @SW_MAXIMIZE) ; Just WinWait() for using WinMenuSelectItem() If WinWait("Impromptu","",5) Then WinMenuSelectItem("Impromptu", "", "&Report", "&Prompt..." ) WinWait("Prompts","") If Not WinActive("Prompts","") Then WinWaitActive("Prompts", "") WinWaitActive("Prompts","") ;send params Send("RPOA" & "{ENTER}") ;BlockInput(1) ;WinSetState("Impromptu", "", @SW_MINIMIZE) MouseMove(110, 175) ;_MouseTrap(60,155,160,200) ProgressOn("Generowanie pliku PDF", "dla rewiru POA", "proszę czekać...") $x=0 Do ;MsgBox(0, "Generowanie pliku PDF", "dla rewiru " & $file, 1) ProgressSet($x) $x=$x+10 Sleep(1000) Until MouseGetCursor()<>15 ProgressSet(100) ProgressOff() WinMenuSelectItem("Impromptu", "", "&File", "Save &As..." ) ; ; Use WinWaitActive() for Send() If WinWait("Save As", "", 5) Then MsgBox (0,"A","",1) While WinExists("Impromptu") And WinExists("Save As") And Not WinActive("Save As") WinActivate("Save As") Sleep(250) WEnd MsgBox (0,"B","",1) If WinWaitActive("Save As", "", 5) Then Send("C:\inetpub\ftproot\RepliGo\test{ENTER}") Send("{TAB}p+{TAB}{ENTER}") EndIf EndIf MsgBox (0,"C","",1) ; Sleep(1000) WinClose("Impromptu") ;WinKill("Impromptu") Sleep(500) EndIf Next Edited August 23, 2006 by 3telnick Link to comment Share on other sites More sharing options...
MHz Posted August 23, 2006 Share Posted August 23, 2006 You were using WinWaitActive instead of WinActivate. That will not Activate if needed. If Not WinActive("Prompts","") Then WinWaitActive("Prompts", "")The MsgBox that I commented would have spoiled the latter WinActivate. Try testing this. expandcollapse popupFor $i = 1 To 1 Run("E:\Program Files\Cognos\cer4\bin\impadmin.exe", "e:\Program Files\Cognos\cer4\bin\", @SW_MAXIMIZE) ; Just WinWait() for using WinMenuSelectItem() If WinWait("Impromptu","",5) Then WinMenuSelectItem("Impromptu", "", "&Report", "&Prompt..." ) WinWait("Prompts") While WinExists("Prompts") And Not WinActive("Prompts") WinActivate("Prompts") Sleep(250) WEnd WinWaitActive("Prompts") ;send params Send("RPOA" & "{ENTER}") ;BlockInput(1) ;WinSetState("Impromptu", "", @SW_MINIMIZE) MouseMove(110, 175) ;_MouseTrap(60,155,160,200) ProgressOn("Generowanie pliku PDF", "dla rewiru POA", "prosze czekac...") $x=0 Do ;MsgBox(0, "Generowanie pliku PDF", "dla rewiru " & $file, 1) ProgressSet($x) $x=$x+10 Sleep(1000) Until MouseGetCursor()<>15 ProgressSet(100) ProgressOff() WinMenuSelectItem("Impromptu", "", "&File", "Save &As..." ) ; ; Use WinWaitActive() for Send() If WinWait("Save As", "", 5) Then MsgBox (0,"A","",1) While WinExists("Impromptu") And WinExists("Save As") And Not WinActive("Save As") WinActivate("Save As") Sleep(250) WEnd ;MsgBox (0,"B","",1) If WinWaitActive("Save As", "", 5) Then Send("C:\inetpub\ftproot\RepliGo\test{ENTER}") Send("{TAB}p+{TAB}{ENTER}") EndIf EndIf MsgBox (0,"C","",1) ; Sleep(1000) WinClose("Impromptu") ;WinKill("Impromptu") Sleep(500) EndIf Next Link to comment Share on other sites More sharing options...
3telnick Posted August 24, 2006 Author Share Posted August 24, 2006 I've tried code modified by you and on 7 attempts 6 are negative 1 is positive. So seems to be "even worse" ... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now