Jump to content

_Console UDF


AlmarM
 Share

Recommended Posts

Hello,

I made this small cool looking Console Project. You can basicly save the actions that are taking by a user.

Console.au3

#include-once

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

; #INDEX# =============================================================================
; Title .........: Console
; AutoIt Version.: 3.3.++
; Language.......: English
; Description ...: Basicly makes a simple console that can be used for saving actions.
; Author ........: Almar Mulder (AlmarM)
; =====================================================================================

Global $Debug_Text

; #FUNCTION# ==========================================================================
; Name...........: _Console_Startup()
; Description ...: Creates a Console
; Syntax.........: _Console_Startup()
; Parameters ....: -
; Return values .: -
; Author ........: Almar Mulder (AlmarM)
; Modified.......: -
; Remarks .......: -
; Related .......: _Console_Write(), _Console_Log()
; Link ..........: -
; Example .......: Yes
; ====================================================================================
Func _Console_Startup()
    $Console_Base = GUICreate("Console...", 400, 200, 10, 10, $WS_BORDER)
    $Debug_Text = GUICtrlCreateEdit("", 0, 0, 400, 190, $ES_WANTRETURN + $ES_AUTOVSCROLL)
    
    GUICtrlSetBkColor($Debug_Text, 0x000000)
    GUICtrlSetColor($Debug_Text, 0xFFFFFF)
    GUISetState()
EndFunc     ;==> _Console_Startup()

; #FUNCTION# =========================================================================
; Name...........: _Console_Write()
; Description ...: Writes text in the Console
; Syntax.........: _Console_Startup($sText, $sEnter = 0, $sOption = 0)
; Parameters ....: $sText, $sEnter, $sOption
;               | $sText = The text to be written
;               | $sEnter = Set to 1 if an enter should be included
;               | $sOption = Set to 1 if timestamp should be included
; Return values .: -
; Author ........: Almar Mulder (AlmarM)
; Modified.......: -
; Remarks .......: -
; Related .......: _Console_Log(), _Console_Startup()
; Link ..........: -
; Example .......: Yes
; ====================================================================================
Func _Console_Write($sText, $sEnter = 0, $sOption = 0)
    If $sEnter = 1 Then
        $x = @CRLF
    Else
        $x = ""
    EndIf
    
    If $sOption = 1 Then
        $TimeStamp = "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] "
    Else
        $TimeStamp = ""
    EndIf
    
    GUICtrlSetData($Debug_Text, $TimeStamp & $sText & $x, "|")
EndFunc     ;==> _Console_Write()

; #FUNCTION# =========================================================================
; Name...........: _Console_Log()
; Description ...: Reads the console and writes a log file (.txt)
; Syntax.........: _Console_Log($sPath)
; Parameters ....: $sPath
;               | $sPath = The path (and file name)
; Return values .: -
; Author ........: Almar Mulder (AlmarM)
; Modified.......: -
; Remarks .......: -
; Related .......: _Console_Startup(), _Console_Write()
; Link ..........: -
; Example .......: Yes
; ====================================================================================
Func _Console_Log($sPath)
    $Log_Text = GUICtrlRead($Debug_Text)
    
    FileWrite($sPath, $Log_Text)
EndFunc     ;==> _Console_Log()

Tell me what you think :P

AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

  • 8 months later...

Very Useful! Thanks!

Edit i did make one little mod though,

Func _Console_Log($sPath, $iOverwrite)
    $Log_Text = GUICtrlRead($Debug_Text)

    If $iOverwrite = 1 Then
        FileDelete($sPath)
    EndIf

    FileWrite($sPath, $Log_Text)
EndFunc   ;==>_Console_Log

Just because if you made the log file "test.log" it would need to overwrite, bu instead the UDF appends the new log text onto the end.

Edited by insignia96

Visit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower

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...