Jump to content

console-alike / log on gui


Recommended Posts

Hey everyone,

so I've been using autoit console as a logger for the current instance to keep track if everything is happening correctly and also the times of execution. I've been doing something along with this:

$time = @HOUR & ":" & @MIN & ":" & @SEC & ":" &@MSEC
ConsoleWrite($time & ": Action goes here" & @ LF)

And with this I actually get a little cool log of everything happening along with the times. But now I want to add something like that to the GUI of my program, I've tried using an edit, as read only, and do something like:

$time = @HOUR & ":" & @MIN & ":" & @SEC & ":" &@MSEC

$temp = $time & ": Action goes here" & @LF
guictrlsetdata ($log, $temp)

in this case it keep replacing the output so I don't really get what has happened before, just what's happening

$time = @HOUR & ":" & @MIN & ":" & @SEC & ":" &@MSEC

$temp = $temp & $time & ": Action goes here" & @LF
guictrlsetdata ($log, $temp)

here the @lf is just ignored and writes everything in one endless line.

So that's it, don't really have any other ideas to make this work, I'm open to critics!

Sorry if this is as common question but I've done some research and haven't found much related to this.

Thanks in advance

Link to comment
Share on other sites

Blackmore,

Define an edit control like this

$e1 = GUICtrlCreateEdit("", 50, 120, @DesktopWidth - 150, 400, $ES_AUTOVSCROLL + $WS_VSCROLL + $ws_hscroll + $es_readonly) GUICtrlSetLimit($s1, 1000000) ; 1 million byte edit char limit

and populate it like this

GUICtrlSetData($e1, _Now() & " " & $some_string & @CRLF, 1)

kylomas

edit: the _now() is just how I do date/time stams, use whatever you like

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

oh sweet! I'll give it a try

Didn't know _now() usage, thanks for that too.

Thank you very much

Edit: worked as a charm, just one more thing, _now() uses date.au3, you forgot to mention that. Thanks again

Edited by BlackMore
Link to comment
Share on other sites

Global $C1 = _PseudoConsole("troll window",0xFF0000)
Global $C2 = _PseudoConsole("fresh rape: $2.95")

Global $Wins = DllStructCreate('hwnd[2]')
DllStructSetData($Wins, 1, WinGetHandle($C1[0]), 1)
DllStructSetData($Wins, 1, WinGetHandle($C2[0]), 2)
DllCall('user32.dll', 'ushort', 'TileWindows', 'hwnd', 0, 'uint', False, 'ptr', 0, 'uint', 2, 'ptr', DllStructGetPtr($Wins))

_InitTrollUser()

Func _PseudoConsole($Title = 0, $txt = 0x00ff00, $bg = 0)
    Local $hwnd[2]
    If Not $Title Then $Title = "Console Debug Info"
    $hwnd[0] = GUICreate($Title, 617, 311, -1, -1, 0x00070000)
    GUISetBkColor($bg)
    $hwnd[1] = GUICtrlGetHandle(GUICtrlCreateEdit("", 0, 0, 617, 311))
    GUICtrlSetResizing(-1, 1)
    GUICtrlSetFont(-1, 10, 500, "", "Consolas")
    GUICtrlSetBkColor(-1, $bg)
    GUICtrlSetColor(-1, $txt)
    GUISetState(@SW_SHOW)
    Return $hwnd
EndFunc

Func _ConsoleWrite($Console, $data)
    If Not $data Then Return 0
    If StringRight($data, 1) = @CR Then $data &= @LF
    DllCall("user32.dll", "none", "SendMessageW", "hwnd", $Console[1], "uint", 0xC2, "wparam", 2, "wstr", $data)
    Return 1
EndFunc   ;==>ConsoleWrite2

Func _InitTrollUser()
    Beep(500,100)
    Beep(1000,100)
     _ConsoleWrite($C1, "They see me trolling ery day!" & @cr)
     _ConsoleWrite($C2, "crip talk crip walk crip slang crip thang" & @cr)
     Sleep(500)
     _ConsoleWrite($C1, "cause i don giva f*** they see me rolling in mah truk smoking that budah" & @cr)
     _ConsoleWrite($C2, "24 pistols 17 muissiles, takem all to the autoit forums and gevem early dis-missile" & @cr)
     Sleep(250)
     _ConsoleWrite($C1, "I be lurking, smurfin, quirkin!" & @cr)
     _ConsoleWrite($C2, "no referees or wistls, just funkeh dismissiles" & @cr)
     Sleep(450)
     _ConsoleWrite($C1, "cause Ima forum troll baby!" & @cr)
     _ConsoleWrite($C2, "make a few calls n tellem let the batnets loose" & @cr)
     Sleep(600)
    _ConsoleWrite($C1, "you are not safe at this location, please " & @CRLF & "refer to the instruction manual for further assistance..." & @cr)
     _ConsoleWrite($C2, "transmission compleated." & @cr)
     Sleep(600)
    _ConsoleWrite($C1, "Random nonsense text for you " & @CRLF & "system will now be shut down to prevent rape sequence." & @cr)
     _ConsoleWrite($C2, "Nope, just kidding, I have more to tell you :>" & @cr)
     Sleep(600)
    _ConsoleWrite($C1, "OH NOES!!!1!11, this book says that the time for propagation had commenced.." & @cr)
     _ConsoleWrite($C2, "You bloody suioerwht7oertoiu" & @cr)
     Sleep(1600)
    Beep(1000,100)
    Beep(500,100)
EndFunc

Edited by ApudAngelorum
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...