Sign in to follow this  
Followers 0
Myfault

Log Window

7 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Thanks Melba...

i'm not a total beginner but need to learn a lot :)

now my script log what i want but only on button click....there's a way to log without click on button and do log event inside function1 ?

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  
Followers 0