Jump to content

[SOLVED] How to send the console output to a file


Recommended Posts

I have searched for almost an hour and I still cannot find examples and or the code that I am looking for concerning my question. 

I am wanting to capture/read/send (however you want to say it) the console output to a file.

Here is a picture of what I want to send to a file after the script runs. (what is in the console output/window after the script runs)

289253598_Screenshot(38).thumb.png.7511facd33720f944872bf75e2c1d2c7.png

 

Edited by nooneclose
Problem solved
Link to comment
Share on other sites

I'm not sure there is a way to do this within the executing script as it is something being handled by the SciTE editor and not the autoit interpreter.  You would need an external script or other means to capture and save the output.

Link to comment
Share on other sites

If you run a compiled script, you can redirect ConsoleWrite() output to a file: C:\...\MyProg >file.txt

You can perhaps redirect Scite console similarly by redirecting stdout when launching SciTE (not tried).

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

I edit my script too often (several times per hour, 40 hours a week) to keep re-compiling it. (until it is done) 

if there isn't a way that's fine I guess. I will just keep copying and pasting it manually. 

I cannot run two different scripts (I think) because my main code, which is not in the picture and over 7k lines, is a bot. I do not want another script running while the bot is running. 

Thank you for your advise and time :D If anyone else has an idea please share. 

Edited by nooneclose
grammar
Link to comment
Share on other sites

@nooneclose, from the image you attached, i cannot understand what is it that you want to capture. if it is some console output from your script that is made by calling ConsoleWrite(), then you can quite easily replace your ConsoleWrite() calls with a custom function to send the output to a file. if it is some stats about the operation of the script, then you'd better describe it more clearly if you are to expect some further help.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

@orbs I was trying to use the green box as a highlighter in the picture to show what I wanted to capture. 

I have many "consoleWrite" throughout my actual script. Is there a way for a single function to tell all of them to write to a file or will I have to edit each one? 

Link to comment
Share on other sites

add a function called something like _ConsoleFileWrite() which accepts a single string parameter, exactly like ConsoleWrite(). inside this function you will pass the string parameter to a standard FileWrite() command with a predetermined file name.

once that is set up, use SciTE menu Search -> Replace... to replace all your ConsoelWrite to _ConsoleFileWrite, and you're set to go.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

@orbs I figured it out on my own. Thanks for trying to help though. :) 

Here is what I used to get the console output to a file. 

 

Local Const $sFilePath = _WinAPI_GetTempFileName("C:\Users\?\Desktop\General\AutoIt_Stuff\AU3 include files\LOG\")
Local $hFileOpen = FileOpen($sFilePath, 1)

Local $hWnd = WinWait("[CLASS:SciTEWindow]", "", 10)
Local $sText = ControlGetText($hWnd, "", "Scintilla2")
        
_FileWriteLog($sFilePath, $sText)
FileClose($hFileOpen)

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...