JohnJonzz Posted July 23, 2009 Share Posted July 23, 2009 Hello everyone! I hope someone can shed some light on what I'm doing wrong in the following script. What is supposed to happen is that the script reads the records (record layout is AAAAAAN.NNN.NNN) in a file (loaded by me) and for each record it substrings the information into a window and runs a report, output as a .PDF. When there is only 1 record, it works properly. The problem is when there is more than one record, the 1st record works properly and the following records output a blank form, which I have to fill manually, instead of being automatically filled in with the record data and after that is done, I press "continue" it then proceeds to fill in the 2nd form and run the job. Thank you very much for your help! JohnJonzz ;================================================ ; Print Software Components by Custom Parts | ;================================================ AutoItSetOption("WinWaitDelay", 200) AutoItSetOption("WinTitleMatchMode", 4) AutoItSetOption("WinDetectHiddenText", 1) AutoItSetOption("MouseCoordMode", 0) AutoItSetOption("SendKeyDelay", 25) ;======================================== ; Open file for reading ;======================================== $file = FileOpen("c:\Auto_SolutionToProcess.txt", 0) ;======================================== ; Check if file opened for reading OK ;======================================== If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ;======================================== ; Read in 1 record at a time until EOF is reached ;======================================== While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop If Not StringIsSpace($line) Then $Prjinit = StringLeft($line, 2) $PrjinitSeq = StringMid($line, 3, 5) $PrjPart = StringMid($line, 9, 3) $PrjCustPart = StringRight($line, 3) ShellExecutewait("Dev0 - PrintSoftwareCompbyCustomPart.bwc", "", "C:\Program Files\Baan\lib\user\") WinWaitActive("ttadv1476m000 : Print Software Components by Customization Part [000]", "") Send("{SHIFTDOWN}" & $Prjinit & "{SHIFTUP}" & $PrjinitSeq & "{TAB}{TAB}" & $PrjPart & "{TAB}{TAB}" & $PrjCustPart & "{TAB}{TAB}") Send("^y") WinWaitActive("ttstpsplopen : Select Device [000]", "") Send("{TAB}{TAB}PDFCONV{TAB}\\a2473\c$\" & $Prjinit & "{SHIFTUP}" & $PrjinitSeq & $PrjPart & $PrjCustPart & "{TAB}") Send("^y") WinWaitActive("ttadv1476m000 : Print Software Components by Customization Part [000]", "", "") If @error = -1 Then MsgBox(2, "Error", "Unable to print.") EndIf Sleep(250) WinClose("ttadv1476m000 : Print Software Components by Customization Part [000]", "") Sleep(125) EndIf WEnd FileClose($file) ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Link to comment Share on other sites More sharing options...
Frog Posted July 23, 2009 Share Posted July 23, 2009 It's just an observation, and maybe not your problem; you're using WinWaitActive(), but not actually making sure that the window is activated, so the script could be waiting until that window is active. You should use a combination of winwait() and winactivate() instead to ensure that you're getting the window you want. Link to comment Share on other sites More sharing options...
JohnJonzz Posted July 24, 2009 Author Share Posted July 24, 2009 It's just an observation, and maybe not your problem; you're using WinWaitActive(), but not actually making sure that the window is activated, so the script could be waiting until that window is active. You should use a combination of winwait() and winactivate() instead to ensure that you're getting the window you want.Frog, sorry it took a while to respond. Your observation was right on (and yes, it was my problem). As per your suggestion I replaced the WINWAITACTIVE(), after the SEND..., with WINWAIT..., followed by IF NOT WINACTIVE... THEN WINACTIVATE... and it worked great. Thank you very much! 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