Varian Posted January 31, 2011 Share Posted January 31, 2011 (edited) I may not understand what you are trying to explain, but I did not include the actual loop in that snippet. I was just telling the OP that one can use a function after the ContinueLoop if one were so inclined. This could be useful in certain instances. For example, while looping through an array that has been created from reading a file, you could check to see if the element is blank. If it is blank, you could Continue the loop and delete that element. Or in a timed loop, you could check for some situation to be exist, and if it does not exist, you could write the lack of existence of that situation to a log file. I am not sure if you are questioning the syntax of my snippet or the value of it. It is equivalent (although not necessarily as valuable) to returning a value from a function. Edited January 31, 2011 by Varian Link to comment Share on other sites More sharing options...
anandnz Posted February 1, 2011 Author Share Posted February 1, 2011 (edited) I am trying this for time out to exit from a while loop .. as winwait doesn't work as system is locked. Any comments. $runtime = Run("....exe", "") $current_Time = TimerInit() $break_time = & $Scripts[$cnt][2] While TimerDiff($current_Time ) < $break_time Sleep(50) if winexists() then blah blah ExitLoop WEnd Exit Edited February 1, 2011 by anandnz Link to comment Share on other sites More sharing options...
Varian Posted February 1, 2011 Share Posted February 1, 2011 I am trying this for time out to exit from a while loop .. as winwait doesn't work as system is locked. Any comments. $runtime = Run("....exe", "") $current_Time = TimerInit() $break_time = & $Scripts[$cnt][2] While TimerDiff($current_Time ) < $break_time Sleep(50) if winexists() then blah blah ExitLoop WEnd Exit The snippet you have there will work. You should be able to use WinWait, however. The portions that I told you to remove in my earlier post were WinActivate and WinWaitActive. According to the Wiki, you cannot activate a window while the computer is locked, but you can check for its' existence (WinExists) and thusly wait on it (WinWait) Link to comment Share on other sites More sharing options...
anandnz Posted February 1, 2011 Author Share Posted February 1, 2011 Thank you again Varian, Yes as you suggested i am using winwait() but for some reason the license to the third party run is released, there is no document which is publishing but script keeps running instead of moving to next document. not sure how to debug it. I will get back with details. Thanks and Regards -- Anand Link to comment Share on other sites More sharing options...
anandnz Posted February 1, 2011 Author Share Posted February 1, 2011 (edited) Hi Varian,Oops I ran into issues,Any idea why the parameter Local $Scripts[34][4] = [["TemplateA",$commondir & "TemplateA.bat", 50000, False], _ WinWait("Information","",$Scripts[$Cnt][2]) The timer passed as a parameter does not work. If i replace with a number it does. How to handle a situation that as i wait for a particular window, some expected window pop up but i need know what the window is and click ok, print the information read ( title, class, etc ) and continue ahead. If i winwait with timeout on all known scenarios, i am not sure it's going to work. Any advice.Note: None of the window dialog boxes that pop up are at definite times or sequence.One of the windows which might come breaking my scripts is this:Title Microsoft Office Word, class #32770Auto recorder, coded the window as this _WinWaitActivate("classname=Shell_TrayWnd","")similarly other might pop up as i wait for the actual window.Thanks in Advance --Anand Edited February 1, 2011 by anandnz Link to comment Share on other sites More sharing options...
Varian Posted February 1, 2011 Share Posted February 1, 2011 Can you post your entire script so that I may better understand what's going on? I want to see how you have declared your Array. Link to comment Share on other sites More sharing options...
anandnz Posted February 1, 2011 Author Share Posted February 1, 2011 Can you post your entire script so that I may better understand what's going on? I want to see how you have declared your Array.okay .. go back to office in 1/2 hour and do that. Link to comment Share on other sites More sharing options...
anandnz Posted February 1, 2011 Author Share Posted February 1, 2011 (edited) Hi Varian,Here is complete code. This is massive document publisher.. so i expect lot of windows, document messages before or after i get the message i would be interested. All i expect is to capture every other message expect the ones intended and press enter, save the PID, Title etc into fail log with file name. 2. WinWait("Information","",$Scripts[$Cnt][2]) does not seem to work.3. Program is stuck up somewhere and never comes out. Note: I changed file names for propreitary reasons. Also array goes to 60 and it grows upwards.I will clean up the log files handling after i get all of it working of course with help ..expandcollapse popup#cs ---------------------------------------------------------------------------- #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here ; TO enable/disable all scripts at one place ; To create all directory locations at one place ; To create pass and fail log files. ; To handle all errors positively to complete the loop and come out of the programming. ;NOTE: ; To run this script, PC must have installed AutoIT installed. ; I am yet to test the compiled version on other system. ; Time out tested are too high, i need a few test runs to find the realistic Time + Buffer so that i can exist in case. ; #include <File.au3> #include <Array.au3> Local $passlog = "c:\AutoIT_Script_documents\Publishlogs\passlog\Passlog.txt" Local $faillog = "c:\AutoIT_Script_documents\Publishlogs\faillog\faillog.txt" Local $common = "c:\AutoIT_Script_documents\Publishlogs\scripts" Local $killall = "c:\AutoIT_Script_documents\Publishlogs\scripts\kill_all.bat" Local $passflg = 1 Local $failflg = 1 ; The below array controls all the scripts, batchfile to copy at one place. ;Any addition of new template for document publication has to be done here by adding a row ( make sure increase the row array and add a row. ;There is no sequence, but index is usually run in the end of the files obviously. ; Do not use winactive commands as they do not work when system is locked. bummer spent a long time to replace them ; A lot of iterations of testing needed to find all the possible windows to handle. ; Local $Scripts[10][4] = [["a",$common & "b.bat", 50000, True], _ ["b",$common & "b.bat", 500000, True], _ ["c",$common & "c", 500000, True], _ ["d",$common & "d.bat",50000,True], _ ["e",$common & "e.bat",50000,True], _ ["f",$common & "f.bat",50000,True], _ ["g",$common & "g.bat",50000,True], _ ["h",$common & "h.bat",50000,True], _ ["i",$common & "i.bat",50000,True], _ ["j",$common & "j.bat",50000,True]] ;_ArrayDisplay($Scripts); Enabling this will have all the listing in the spread sheet. For $cnt = 0 To UBound($Scripts) - 1 If $Scripts[$cnt][3] Then ;local $runtime = Run($killall) ; Ensure all applications are closed and temporary files deleted, "This if the control comes here breaking frm loop" ;Local $current_Time = TimerInit() Local $break_time = $Scripts[$cnt][2] Local $DocPub = 1 Local $handle = 0 ;ConsoleWrite("The batch file is " & $Scripts[$cnt][1] & @CRLF) ;ConsoleWrite("The Maximum Time out is " & $Scripts[$cnt][2] & @CRLF) Run("set PATH=C:\Program Files\openfile\bin\exe\win32pc;%PATH%") ; Run once this command to set the path. Actually not needed if the system is already set with path. ;Storing the big string in the command variable so that i can run this whole string .. this comamnd from openfile is not yet explored. $command = "C:\Program Files\openfile\bin\exe\win32pc\" & "openfile.exe -file " & $Scripts[$cnt][0] ConsoleWrite("The break time is " & $break_time & @CRLF) sleep(50) Run($command) ; working hurray ! Yeah .. the openfile command works ConsoleWrite("The openfile command run " & $command & @CRLF) ConsoleWrite("The file publishing is " & $Scripts[$cnt][0] & @CRLF) if WinExists("Cannot Open PDB File") Then ; If this window error box pops up we need to handle it ControlSend("[Title:Cannot Open PDB File; CLASS:#32770]", "", "", "{ENTER}") ConsoleWrite("Here is the culprit file" & $Scripts[$cnt][0] & @CRLF) if $failflg Then _FileWriteLog($faillog, "---------------Latest logs below this line---------------------") $failflg = 0 EndIf _FileWriteLog($faillog, "File " & $Scripts[$cnt][0] & " Cannot OpenPDB file ..IS SERVER RUNNING ..OR Does the file to run exists ??") ContinueLoop EndIf if WinExists("Microsoft Office Word") Then ControlSend("[TITLE:Microsoft Office Word; CLASS:#32770]", "", "", "{ENTER}"); command to close it if $failflg Then _FileWriteLog($faillog, "---------------Latest logs below this line---------------------") $failflg = 0 EndIf _FileWriteLog($faillog, "File " & $Scripts[$cnt][0] & " has too many spell erors, is there setting in the project ??") ContinueLoop EndIf $handle = WinWait("Information","",$Scripts[$Cnt][2]) ConsoleWrite(" The handle returned is " & $handle & @CRLF) ControlFocus("Information", "text", "" ) If WinExists("Information") Then ; This is successful completion window and needs a user to close it ControlSend ("[TITLE:Information; CLASS:#32770]", "", "", "{ENTER}"); command to close it if $passflg Then _FileWriteLog($passlog, "---------------Latest logs below this line---------------------") $passflg = 0 EndIf _FileWriteLog($passlog, "File " & $Scripts[$cnt][0] & "------ PASS") sleep(4000) Run($Scripts[$cnt][1]) sleep(4000) $DocPub = 0 EndIf If $DocPub == 1 Then if $failflg Then _FileWriteLog($faillog, "---------------Latest logs below this line---------------------") $failflg = 0 EndIf _FileWriteLog($faillog, "File " & $Scripts[$cnt][0] & "------ FAIL") Run($killall) ; Ensure all applications are closed and temporary files deleted EndIf Else ConsoleWrite("This file is not selected ... " & $Scripts[$cnt][0] & @CRLF) EndIf Next;Any help is appreciated.Thanks a tonRegards--Anand Edited February 1, 2011 by anandnz Link to comment Share on other sites More sharing options...
anandnz Posted February 1, 2011 Author Share Posted February 1, 2011 (edited) Hi I am trying this in this lines from forum help from zfisherdrums Do you agree .. too late in office .. i will let you know the output tomorrow. As of now i am not able to include"#include <A3LWinAPI.au3> " If you ok with this model, please let me know how to have this file included ( if i need it)I am using AdlibRegister() instead of AdlibEnable() which i do not find in the syntax (proably because of include file)Also please let me know about _API_EnumWindows(), will that compare every window which pops up. I think it requires include file. Duh! i have called function SuccessInformation($Scripts[$cnt][0], $Scripts[$cnt][1]), after defining it to handle the success window.However $handle = Run($command) While ProcessExists($handle) ;AdlibRegister("SuccessInformation($File, $batch)", 1000) ; Gives error as undefined.. Try 1 fail ; AdlibRegister("SuccessInformation($Scripts[$cnt][0], $Scripts[$cnt][1])", 1000) ; Try 2 fail ;AdlibRegister("SuccessInformation", 1000); Try 3 fail as i need to pass the file and batch file (2 variables)Then probably i could try for all the windows similarly. Please adviceThanks in advance.-- Anand Edited February 1, 2011 by anandnz Link to comment Share on other sites More sharing options...
Zedna Posted February 1, 2011 Share Posted February 1, 2011 I am using AdlibRegister() instead of AdlibEnable() which i do not find in the syntax (proably because of include file)Post your problematic code with AdlibRegister() ... Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 1, 2011 Share Posted February 1, 2011 As of now i am not able to includeA3LWinAPI.au3 was replaced by WinAPI.au3 (WinAPI Management in helpfile) some years ago. _WinAPI_EnumWindows looks right.I am using AdlibRegister() instead of AdlibEnable() which i do not find in the syntax (proably because of include file)AdlibEnable was replaced by AdlibRegister a year ago (see history in helpfile). .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Varian Posted February 1, 2011 Share Posted February 1, 2011 anandnz, what version of AutoIT are you running, buddy? Let's make sure that we are all on the same level. Link to comment Share on other sites More sharing options...
anandnz Posted February 1, 2011 Author Share Posted February 1, 2011 Hi Varian and Zedna and every one Thank you all Oh yes i figured it out that the post is old. Answer was actually to my questions earlier .. I realized later. I am posting the whole code here after redesigning What i intend to is written as comments in the function. Mostly handling errrors and success and keep the loop going ensure no more than 1 word ducment is ever opened (probably no document, not sure trial and error). expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: Anand Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here ; TO enable/disable all scripts at one place ; To create all directory locations at one place ; To create pass and fail log files. ; To continuosly check for error pop ups and handle them ; To NOT TO LET OPEN ANY WORD DOCUMENT AS more than 300 documents opens up destroying the automation. ;NOTE: ; To run this script, PC must have installed AutoIT installed. ; I am yet to test the compiled version on other system. ; Time out tested are too high, i need a few test runs to find the realistic Time + Buffer so that i can exist in case. ; #include <File.au3> #include <Array.au3> Local $passlog = "c:\AutoIT_Script_documents\Publishlogs\passlog\Passlog.txt" Local $faillog = "c:\AutoIT_Script_documents\Publishlogs\faillog\faillog.txt" Local $common = "c:\AutoIT_Script_documents\Publishlogs\scripts" Local $killall = "c:\AutoIT_Script_documents\Publishlogs\scripts\kill_all.bat" Local $passflg = 1 Local $failflg = 1 Func SuccessInformation ($File, $batch) WinWait("Information","","") ;ConsoleWrite(" The handle returned is " & $handle & @CRLF) ControlFocus("Information", "text", "" ) If WinExists("Information") Then ; This is successful completion window and needs a user to close it ControlSend ("[TITLE:Information; CLASS:#32770]", "", "", "{ENTER}"); command to close it _FileWriteLog($passlog, "File " & $File & "------ PASS") ;_FileWriteLog($passlog, "File " & $Scripts[$cnt][0] & "------ PASS") sleep(4000) ;Run($Scripts[$cnt][1]) Run($batch) sleep(4000) $DocPub = 0 EndIf Sleep(1000) EndFunc Func SpellErrorWord () ; A Dialog box thrown from third party which says, too many spell mistakes and halts the process ; Action .. close the dialog box, word and if the process is not running go to the next loop EndFunc Func OfficedoumentHandler () ; Ensure no word document opened from the Run process If opened, close it(Not kill). ; This is to get over the bug from this third party software which is opening up 300 documents in some instances. EndFunc Func Idlecheck() ; If the run process is idle for a long time, terminate and go to next loop EndFunc ; The below array controls all the scripts, batchfile to copy at one place. ;Any addition of new template for document publication has to be done here by adding a row ( make sure increase the row array and add a row. ;There is no sequence, but index is usually run in the end of the files obviously. ; Do not use winactive commands as they do not work when system is locked. bummer spent a long time to replace them ; A lot of iterations of testing needed to find all the possible windows to handle. ; Local $Scripts[10][4] = [["a",$common & "b.bat", 50000, True], _ ["b",$common & "b.bat", 500000, True], _ ["c",$common & "c", 500000, True], _ ["d",$common & "d.bat",50000,True], _ ["e",$common & "e.bat",50000,True], _ ["f",$common & "f.bat",50000,True], _ ["g",$common & "g.bat",50000,True], _ ["h",$common & "h.bat",50000,True], _ ["i",$common & "i.bat",50000,True], _ ["j",$common & "j.bat",50000,True]] ;_ArrayDisplay($Scripts); Enabling this will have all the listing in the spread sheet. For $cnt = 0 To UBound($Scripts) - 1 If $Scripts[$cnt][3] Then ;local $runtime = Run($killall) ; Ensure all applications are closed and temporary files deleted, "This if the control comes here breaking frm loop" ;Local $current_Time = TimerInit() Local $break_time = $Scripts[$cnt][2] Local $DocPub = 1 Local $handle = 0 ;ConsoleWrite("The batch file is " & $Scripts[$cnt][1] & @CRLF) ;ConsoleWrite("The Maximum Time out is " & $Scripts[$cnt][2] & @CRLF) Run("set PATH=C:\Program Files\openfile\bin\exe\win32pc;%PATH%") ; Run once this command to set the path. Actually not needed if the system is already set with path. ;Storing the big string in the command variable so that i can run this whole string .. this comamnd from openfile is not yet explored. $command = "C:\Program Files\openfile\bin\exe\win32pc\" & "openfile.exe -file " & $Scripts[$cnt][0] ConsoleWrite("The break time is " & $break_time & @CRLF) sleep(50) Run($command) ; working hurray ! Yeah .. the openfile command works ConsoleWrite("The openfile command run " & $command & @CRLF) ConsoleWrite("The file publishing is " & $Scripts[$cnt][0] & @CRLF) While ProcessExists($handle) ;ControlFocus( "Form1", "", "Edit1" ) ;ControlSend( "Form1", "", "Edit1", "Testing the application" & @LF ) AdlibRegister("OfficedoumentHandler", 1000) AdlibRegister("SpellErrorWord", 1000) AdlibRegister("SuccessInformation($File, $batch)", 1000) AdlibRegister("Idlecheck", 1000) ;AdlibRegister("SuccessInformation($File, $batch)", 1000) ; Gives error as undefined.. Try 1 fail ;AdlibRegister("SuccessInformation($Scripts[$cnt][0], $Scripts[$cnt][1])", 1000) ; Try 2 fail ;AdlibRegister("SuccessInformation", 1000); Try 3 fail as i need to pass the file and batch file (2 variables) WEnd ConsoleWrite("The Cradle command run " & $command & @CRLF) ConsoleWrite("The file publishing is " & $Scripts[$cnt][0] & @CRLF) If $DocPub == 1 Then if $failflg Then _FileWriteLog($faillog, "---------------Latest logs below this line---------------------") $failflg = 0 EndIf _FileWriteLog($faillog, "File " & $Scripts[$cnt][0] & "------ FAIL") Run($killall) ; Ensure all applications are closed and temporary files deleted EndIf Else ConsoleWrite("This file is not selected ... " & $Scripts[$cnt][0] & @CRLF) EndIf Next; Yeah ready for next cycle Thanks a ton really. Regards -- Anand Link to comment Share on other sites More sharing options...
anandnz Posted February 3, 2011 Author Share Posted February 3, 2011 Hi experts, I am still not able to use AdlibRegister() with multiple parameters, any one used this with success please, that would help move a bit on my program. Help says, i cannot use blocking calls, so winwait does not work i guess in AdlibRegister(). Thanks in advance -- Anand Link to comment Share on other sites More sharing options...
Varian Posted February 3, 2011 Share Posted February 3, 2011 (edited) You can use WinWait() in an AdLibRegister() function: HotKeySet('{ESC}', '_Quit') _Splash(' ') AdLibRegister('_MsgBox', 3 * 1000) Local $Count While 1 $Count += 1 ControlSetText('[CLASS:AutoIt v3]', '', 'Static1', $Count) If $Count > 5000 Then $Count = 0 Wend ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Functions Start;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func _Splash($Text) ;Shows a small borderless splash message. SplashTextOn('', $Text, 600, 95, -1, 5, 33, '', 10) EndFunc ;==>_Splash Func _MsgBox() If Not WinExists('[CLASS:Notepad]') Then MsgBox(0, '', 'You must now open Notepad to continue the Script', 3) WinWait('[CLASS:Notepad]') EndFunc Func _Quit() Exit EndFunc ;==>_Quit Edited February 3, 2011 by Varian Link to comment Share on other sites More sharing options...
anandnz Posted February 3, 2011 Author Share Posted February 3, 2011 You can use WinWait() in an AdLibRegister() functionHi Varian,Thank you very much. I will probably work to redesign to handle the messages and handle the variable handling which i am not able to pass now with a flag, tomorrow evening. I will let you know how it went, for time out i plan to use _Timer_SetTimer(). I will let you know how it went. Thanks againcheers-- Anand Link to comment Share on other sites More sharing options...
anandnz Posted February 4, 2011 Author Share Posted February 4, 2011 Please can some one review my code and let me know if the approach is right, I need help in the following 1. I have issue with AdlibRegister(), it requires to be deregisters or the program hangs. I cannot register as i have to constantly check for the error messages which pop up ( The kinds of errors i handle are mentioned in the functions) 2. Why does this _Timer_SetTimer () function doesn't work. It never gets called. I am kind o expandcollapse popup#include <File.au3> #include <Array.au3> #include <Timers.au3> Local $passlog = "c:\AutoIT_Script_documents\Publishlogs\passlog\Passlog.txt" Local $faillog = "c:\AutoIT_Script_documents\Publishlogs\faillog\faillog.txt" Local $common = "c:\AutoIT_Script_documents\Publishlogs\scripts" Local $killall = "c:\AutoIT_Script_documents\Publishlogs\scripts\kill_all.bat" Local $passflg = 1 Local $failflg = 1 Func SuccessInformation() WinWait("Information","","") ConsoleWrite("I am in the AdlibRegister function" & @CRLF) ControlFocus("Information", "text", "" ) If WinExists("Information") Then ; This is successful completion window and needs a user to close it ControlSend ("[TITLE:Information; CLASS:#32770]", "", "", "{ENTER}"); command to close it ConsoleWrite(" The window is closed !!!" & @CRLF) $CradleSuccess = 1 AdlibUnRegister("SuccessInformation") EndIf EndFunc Func SpellErrorWord () ; A Dialog box thrown from third party which says, too many spell mistakes and halts the process ; Action .. close the dialog box, word and if the process is not running go to the next loop EndFunc Func OfficedoumentHandler () ; Ensure no word document opened from the Run process If opened, close it(Not kill). ; This is to get over the bug from this third party software which is opening up 300 documents in some instances. EndFunc Func Idlecheck() ; If the run process is idle for a long time, terminate and go to next loop EndFunc Func _TimeExpired () ConsoleWrite("This is the timer expiry function" & @CRLF) $DocTimer = 0 EndFunc ; The below array controls all the scripts, batchfile to copy at one place. ;Any addition of new template for document publication has to be done here by adding a row ( make sure increase the row array and add a row. ;There is no sequence, but index is usually run in the end of the files obviously. ; Do not use winactive commands as they do not work when system is locked. bummer spent a long time to replace them ; A lot of iterations of testing needed to find all the possible windows to handle. ; Local $Scripts[10][4] = [["a",$common & "b.bat", 50000, True], _ ["b",$common & "b.bat", 500000, True], _ ["c",$common & "c", 500000, True], _ ["d",$common & "d.bat",50000,True], _ ["e",$common & "e.bat",50000,True], _ ["f",$common & "f.bat",50000,True], _ ["g",$common & "g.bat",50000,True], _ ["h",$common & "h.bat",50000,True], _ ["i",$common & "i.bat",50000,True], _ ["j",$common & "j.bat",50000,True]] ;_ArrayDisplay($Scripts); Enabling this will have all the listing in the spread sheet. For $cnt = 0 To UBound($Scripts) - 1 If $Scripts[$cnt][3] Then ;local $runtime = Run($killall) ; Ensure all applications are closed and temporary files deleted, "This if the control comes here breaking frm loop" ;Local $current_Time = TimerInit() Local $break_time = $Scripts[$cnt][2] Local $DocPub = 1 Local $handle = 0 ;ConsoleWrite("The batch file is " & $Scripts[$cnt][1] & @CRLF) ;ConsoleWrite("The Maximum Time out is " & $Scripts[$cnt][2] & @CRLF) Run("set PATH=C:\Program Files\openfile\bin\exe\win32pc;%PATH%") ; Run once this command to set the path. Actually not needed if the system is already set with path. ;Storing the big string in the command variable so that i can run this whole string .. this comamnd from openfile is not yet explored. $command = "C:\Program Files\openfile\bin\exe\win32pc\" & "openfile.exe -file " & $Scripts[$cnt][0] ConsoleWrite("The break time is " & $break_time & @CRLF) sleep(50) $handle = Run($command) ; working hurray ! Yeah .. the openfile command works ConsoleWrite("The openfile command run " & $command & @CRLF) ConsoleWrite("The file publishing is " & $Scripts[$cnt][0] & @CRLF) AdlibRegister("SuccessInformation", 1000) ;AdlibRegister("SpellErrorWord", 1000); Can i handle multiple Adlib register calls? ;AdlibRegister("Idlecheck", 1000) ;AdlibRegister("OfficedoumentHandler", 1000) _Timer_SetTimer($handle, 50, "_TimeExpired") ; create timer While ProcessExists($handle) ;ConsoleWrite("I am in while process exists loop" & @CRLF) ;_Timer_SetTimer($handle, 50000000, "_TimeExpired") ; create timer ControlFocus("Information", "text", "" ) WEnd ConsoleWrite("The Cradle command run " & $command & @CRLF) ConsoleWrite("The file publishing is " & $Scripts[$cnt][0] & @CRLF) If $DocPub == 1 Then if $failflg Then _FileWriteLog($faillog, "---------------Latest logs below this line---------------------") $failflg = 0 EndIf _FileWriteLog($faillog, "File " & $Scripts[$cnt][0] & "------ FAIL") Run($killall) ; Ensure all applications are closed and temporary files deleted EndIf Else ConsoleWrite("This file is not selected ... " & $Scripts[$cnt][0] & @CRLF) EndIf Next; Yeah ready for next cycle Thanks in Advance, -- Anand Link to comment Share on other sites More sharing options...
Varian Posted February 4, 2011 Share Posted February 4, 2011 I cannot test your script because I do not have the openfile program, but I can see your dilemma. When I run the script, it hangs on the Winwait in the AdLibRegister call. Perhaps you can make it more useful by using a Select...Case loop in the "SuccessInformation" function. Func SuccessInformation() Local $Start = TimerInit() While 1 Select Case WinExists("Information", "") ConsoleWrite("I am in the AdlibRegister function" & @CRLF) ControlFocus("Information", "text", "") If WinExists("Information") Then ; This is successful completion window and needs a user to close it ControlSend("[TITLE:Information; CLASS:#32770]", "", "", "{ENTER}"); command to close it ConsoleWrite(" The window is closed !!!" & @CRLF) $CradleSuccess = 1 AdlibUnRegister("SuccessInformation") EndIf Case WinExists("SpellErrorWord Window") SpellErrorWord() EndSelect If TimerDiff($Start) >= 1 * 1000 Then ConsoleWrite("I am in the AdlibRegister function ~" & Random(1, 10000) & @CRLF) Return EndIf WEnd EndFunc ;==>SuccessInformation Link to comment Share on other sites More sharing options...
anandnz Posted February 4, 2011 Author Share Posted February 4, 2011 Hi Varian, Yes you are right, I got trapped with names and was using multiple adlibRegister for each function. where as example had one adlibregister with exactly as you said. I haven't realized it. Thank you for the timely message. So are these correct lessons to learn. 1.Authenticity, on Mar 11 2009, 01:02 PM, said: () " Use _Timer_SetTimer for multiple timers. AdlibEnable retain the last function name called using AdlibEnable and call it, no multiple Adlib functions." One cannot use multiple Adlibenable() at the same time. .. Or probably a bad practice. Did i miss this in the documentation. 2. I cannot pass variables to the functions called via the adlibenable() But i still did not get why _Timer_SetTimer () is not working for me. I will try to implement you design changes. Thanks a ton as always. Cheers and lot of Thanks -- Anand I cannot test your script because I do not have the openfile program, but I can see your dilemma. When I run the script, it hangs on the Winwait in the AdLibRegister call. Perhaps you can make it more useful by using a Select...Case loop in the "SuccessInformation" function. Func SuccessInformation() Local $Start = TimerInit() While 1 Select Case WinExists("Information", "") ConsoleWrite("I am in the AdlibRegister function" & @CRLF) ControlFocus("Information", "text", "") If WinExists("Information") Then ; This is successful completion window and needs a user to close it ControlSend("[TITLE:Information; CLASS:#32770]", "", "", "{ENTER}"); command to close it ConsoleWrite(" The window is closed !!!" & @CRLF) $CradleSuccess = 1 AdlibUnRegister("SuccessInformation") EndIf Case WinExists("SpellErrorWord Window") SpellErrorWord() EndSelect If TimerDiff($Start) >= 1 * 1000 Then ConsoleWrite("I am in the AdlibRegister function ~" & Random(1, 10000) & @CRLF) Return EndIf WEnd EndFunc ;==>SuccessInformation Link to comment Share on other sites More sharing options...
Varian Posted February 4, 2011 Share Posted February 4, 2011 You are passing the PID to the _Timer_Set_Timer function, not a Window handle. I'm not an expert on this function, but at least from the documentation that is wrong. Please be careful when you use "==". That is calling a case-sensitive string comparison, not a value comparison. I think that you are using "==" in the wrong places (if you need it at all anywhere). The only time that I use "==" is when the case of a string is important, and you should never use it with a non-quoted number like you have. Think of the AdLib function that you are using as a gateway function (for your scenario). All that you want it to do is to check for the existence of windows or the status of process within select...case...endselect loops. If a case is met, unregister the AdLib then run a function for that case. When that function closes, re-register the AdLib function again. 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