dreamzboy Posted April 22, 2008 Share Posted April 22, 2008 Hi All, Before I explain further, please see my codes below as it should give you an understanding of what I'm trying to accomplish. $Success = "All services have started successfully." Run("notepad.exe") WinWaitActive("Untitled - Notepad") If (@HOUR > 12) Then $Hour = @HOUR - 12 Send (@MON & "/" & @MDAY & "/" & @YEAR & "; " & $Hour & ":" & @MIN & " PM" & ". " & $Success) Else Send (@MON & "/" & @MDAY & "/" & @YEAR & "; " & @HOUR & ":" & @MIN & " AM" & ". " & $Success) EndIf Sleep (1000) WinClose("Untitled - Notepad") WinWaitActive("Notepad", "Do you want to save") Send("!y") WinWaitActive("Save As", "Save &in:") Send ("service_log") Sleep (500) Send ("!s") Sleep (1000) If WinActive ("Save As", "Do you want to replace") Then Send ("!y") EndIf Basically, I want all this to be silent instead of windows popping up on the screen doing what it is written in the codes. I want it to be able to keep/save the log file in a directory (anywhere, doesn't matter). The next time that it runs, it writes the log on the next line, save it, and so forth. This way I can refer back to the log file to check whether the installation runs completely or not. A hint: if the log file exists, check for empty line to write the success comment, and save. Else, create a new log.txt file, writes to first available space, and then save. I searched the knowledge base, couldn't find much that fits what I wanted it to do nor do I know much about silent logging. Please shed some lights if this is your expertise. Much appreciated. Link to comment Share on other sites More sharing options...
evilertoaster Posted April 22, 2008 Share Posted April 22, 2008 It will probably be much easier with FileWrite() or FileWriteLine() than trying to script notepad in the backround. Link to comment Share on other sites More sharing options...
TheCuz Posted April 22, 2008 Share Posted April 22, 2008 If there is no specific reason for using notepad, why not just use FileWrite or FileWriteLine? Good examples of how to use both is in the help file. [font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font] Link to comment Share on other sites More sharing options...
TheCuz Posted April 22, 2008 Share Posted April 22, 2008 It will probably be much easier with FileWrite() or FileWriteLine() than trying to script notepad in the backround.LOL...pretty much the same thing written at the same time.... [font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font] Link to comment Share on other sites More sharing options...
dreamzboy Posted April 22, 2008 Author Share Posted April 22, 2008 Thanks guys for the quick pointer. I'll look that up. How will this differentiate if the first line is already written? I assume I'll have to use isString? Link to comment Share on other sites More sharing options...
monoceres Posted April 22, 2008 Share Posted April 22, 2008 Thanks guys for the quick pointer. I'll look that up. How will this differentiate if the first line is already written? I assume I'll have to use isString?This will append do end of file: $handle=Filopen("filename.txt",1) FileWriteLine($handle,"Debug!") FileClose($handle) Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
dreamzboy Posted April 22, 2008 Author Share Posted April 22, 2008 Wow, pretty simple. $file = FileOpen("test.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, "Line1") FileWrite($file, "Still Line1" & @CRLF) FileWrite($file, "Line2") FileClose($file) I think I'm all set. Thanks again guys! 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