Jump to content

Modify text of CUI


Recommended Posts

I have seen programs that, instead of creating new lines of text, overwrite previous lines. This is used mainly for tracking progress.

For example, the console will show 0.0%, and as something loads, the 0.0% will be replaced by the new percent, instead of just writing more and more lines.

Does anyone know of a way to do this?

I was thinking ControlSetText but I couldn't find the Control. Only the window class.

Link to comment
Share on other sites

It's all in how you format the output. Compile this and run the EXE from a command line:

#AutoIt3Wrapper_Change2CUI=Yes

For $n = 1 To 10
    Consolewrite("Test0 = " & $n)
    Sleep(500)
Next
ConsoleWrite(@CRLF & @CRLF)

; Compare with...
For $n = 1 To 10
    Consolewrite("Test1 = " & $n & @CR)
    Sleep(500)
Next
ConsoleWrite(@CRLF & @CRLF)

; And compare with...
For $n = 1 To 10
    Consolewrite("Test2 = " & $n & @LF)
    Sleep(500)
Next

Notice that when you only use @CR without the @LF it overwrites the same line.

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I don't think you can do that on a standard CMD console. It's just basic line formatting (inherited from teletypes). You could define the display size of the console (default is 24 lines), and output one full "page" of data at time, which will have the same effect as a display refresh:

#AutoIt3Wrapper_Change2CUI=Yes

; For 24 line console
For $x = 1 To 10
    $sMsg = "Test Console -- Top" & @CRLF ; Line 1
    For $n = 1 To 6 ; Lines 2 thru 7 = whitespace
        $sMsg &= @CRLF
    Next
    For $n = 1 To 5 ; lines 8 thru 17 = data
        $sMsg &= "Test" & $n & " = " & $x & @CRLF & @CRLF
    Next
    For $n = 1 To 6 ; lines 18 thru 23 = whitespace
        $sMsg &= @CRLF
    Next
    $sMsg &= "Test Console -- Bottom" & @CRLF ; line 24
    ConsoleWrite($sMsg)
    Sleep(2000)
Next

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I believe you can do this using commands to the ANSI driver for DOS, but I lost interest in that layer loooong ago. Google is yo...

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...