Jump to content

Log Window


Myfault
 Share

Recommended Posts

Hi all,

i'm doing some scripts in Autoit and it is fun ...It's a real powerfull tool..and i want to thak you all for the infos in this forum.

I searched in forum but i didn't find nothing about this...

My problem is:

1) i have a script (main.au3) that do something in steps way

IE(no real code):

Main()

Func Main($state)

switch

case = 1

do something

case = 2

do else

Endfunc

Func 1

..

$state=1

Return $state

Endfunc

Func 2

...

$state=2

Return $state

Endfunc

2) I wish to create a au3 (log.au3) with gui creation that write into an edit control and write into a txt file messages sended by every func in main.au3

i tried onevent but with no luck.

Thanks

Link to comment
Share on other sites

  • Moderators

Myfault,

First, welcome to the AutoIt forums.

Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously.

You should also look at the excellent tutorials that you will find here and here.

That will help you with writing proper AutoIt code based on what you have posted.

For your second question, look in the Help file at GUICtrlSetData for getting the messages into an Edit control and _FileWriteLog for the text file.

Come back and ask again when you run into problems. When you post the code you have produced, please put CODE tags around it to help others see it more clearly. Just place [code ] before and [/code ] afterwards (leave out the spaces at the end of the tags - they are only there so the tags show in this post!).

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

hi,

thanks Melba23.

I try to explain better my problem.

My main.au3 work well and do all i want (400 lines of code), now i need to log single operations from main.au3 to a log window and a txt file.

example: main.au3

#include "log.au3"
function1()

Func function1()
;do something 
$variable = 5

;send to log this variable
;here is the part i don't know
_GUICtrlEdit_AppendText($editctrl,$variable)
EndFunc

log.au3

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 193, 115)
$editctrl = GUICtrlCreateEdit("", 0, 0, 185, 89)
GUICtrlSetData(-1, "editctrl")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

what's wrong with this?

thanks

Edited by Myfault
Link to comment
Share on other sites

  • Moderators

Myfault,

Apologies if I took you for a complete beginner. :-)

If you want to use _GUICtrlEdit_AppendText you need to include GuiEdit.au3. This code works fine - just press the button to run the function:

#include <GUIConstantsEx.au3>
#Include <GuiEdit.au3>

$Form1 = GUICreate("Form1", 600, 400, 200, 150)
Global $editctrl = GUICtrlCreateEdit("", 10, 10, 200, 330)

Global $button = GUICtrlCreateButton("Log", 10, 350, 80, 30)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button
            function1()

    EndSwitch
WEnd

Func function1()
;do something 
$variable = "Add this to the editcontrol" & @CRLF

;send to log this variable
_GUICtrlEdit_AppendText($editctrl,$variable)

EndFunc

Hope this helps. Ask if there is anything else.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Myfault,

The _GUICtrlEdit_AppendText is inside the function, so just call the function from within your script and _GUICtrlEdit_AppendText will write to the edit control. I only added the button so that the function could be called when wanted - it serves no purpose other than that.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

thanks...

i know where i was wrong.

i was calling the function from another au3 file.

my project have this files:

main.au3 (all the logic)

var.au3 (variables)

gui.au3 (the gui)

log.au3 (the log)

i was calling log function, that was in log.au3, from inside main.au3.

Now i must only copy all log.au3 code inside main.au3.

thanks again

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