Jump to content

Generate a Real-Time Log in a GUI


Recommended Posts

I hate to open another thread but I could not find the answer through searching and documentation.

I wanted to create a real-time log file in my script using GUICtrlSetData; however, when that function is used, it overwrites the old data.  I've created an Array to handle such case but couldn't get the logic to work the way I'd imagined.  Is there another function that I can use to append?

The final result that I want is

1.  Saving default password into XML Script.
2.  Saving default password into XML Script.
3.  Saving default password into XML Script.
4.  Saving default password into XML Script.

My retarded script :wacko:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

Local $i = 0
Local $log_label[4]

GUICreate ("RIBCL XML Script Generator", 600, 400)
           
GUISetState ()

For $i = 0 To 3 Step 1
   $log_label[$i] = GUICtrlCreateLabel ("", 300, 40, 270, 280, $ss_sunken)
               GUICtrlSetFont (-1, 10, 800)
   GUICtrlSetData ($log_label[$i], $i & ".  Saving default password into XML Script." & @CRLF)
   Sleep (1000)
Next

Thank you!

Link to comment
Share on other sites

  • Moderators

dreamzboy,

I would use a List control - like this:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$cList = GUICtrlCreateList("", 10, 10, 200, 200, BitOr($WS_BORDER, $WS_VSCROLL))

GUISetState()

For $i = 1 To 10
    GUICtrlSetData($cList, $i & ": SEC = " & @SEC)
    Sleep(1000)
Next

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Please ask if you have any questions. :)

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 Melba for the quick response.  I'm getting a few errors regarding declaring some variables which I added; however, it complains about $WS_BORDER and $SW_VSCROLL.  It also complains about "MsgBoxConstants.au3" not being there either.  I'm running SciTE Version 3.3.0.

Here's a modified version of your script.

#include <GUIConstantsEx.au3>
#include <ListBoxConstants.au3>
#include <MsgBoxConstants.au3>

local $hGUI, $cList, $i

$hGUI = GUICreate("Test", 500, 500)

$cList = GUICtrlCreateList("", 10, 10, 200, 200, BitOr($WS_BORDER, $WS_VSCROLL))

GUISetState()

For $i = 1 To 10
    GUICtrlSetData($cList, $i & ": SEC = " & @SEC)
    Sleep(1000)
Next

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Link to comment
Share on other sites

  • Moderators

dreamzboy,

It is the Autoit version that is of interest - I assume you are still on 3.3.8.1 and the includes are for 3.3.9.21 Beta. Sorry about that - I forget that not everyone is that keen on keeping up with the new versions. :(

Try this script - it works fine for me on 3.3.8.1:

#include <GUIConstantsEx.au3>
#include <ListBoxConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

Global $hGUI, $cList ; These are Global regardless of what you tell AutoIt so you might as well use the right Keyword

$hGUI = GUICreate("Test", 500, 500)

$cList = GUICtrlCreateList("", 10, 10, 200, 200, BitOr($WS_BORDER, $WS_VSCROLL)) ; You need to define the styles as the default will sort the entries alphabetically

GUISetState()

For $i = 1 To 10 ; No need to declare loop variables
    GUICtrlSetData($cList, $i & ": SEC = " & @SEC)
    Sleep(1000)
Next

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
I also added a couple of comments re your changes - please ask if you do not understand them. :)

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

Thank you for the extra clarification.  It really helps.

Last question - Is there a way to enable horizontal scrolling?  Some of my texts are being cut-off even when I use $WS_HSCROLL.  The vertical scroll bar automatically applies as the list goes off the designated field but not the horizontal scroll bar.

$log_label = GUICtrlCreateList ("", 300, 40, 270, 280, BitOR($WS_BORDER, $WS_HSCROLL, $WS_VSCROLL))

Much appreciated.

Link to comment
Share on other sites

  • Moderators

dreamzboy,

Interesting - I cannot get it to work either and yet I am sure I have seen it done. :wacko:

So I suggest we move to an edit control - that certainly does work: :D

#include <GUIConstantsEx.au3>
#include <GUIEdit.au3>

Global $hGUI, $cEdit

$hGUI = GUICreate("Test", 500, 500)

$cEdit = GUICtrlCreateEdit("", 10, 10, 200, 200)

GUISetState()

For $i = 1 To 20
    _GUICtrlEdit_AppendText($cEdit, $i & ": just to make it a very long line SEC = " & @SEC & @CRLF)
    Sleep(1000)
Next

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
I will keep looking at the List control when I have a moment and see if I can get it to scroll horizontally. And I should mention that there is a default 64k limit on the text you can fit into an Edit control - use GUICtrlSetLimit to increase it if needed. ;)

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

I'm glad I did something right.  :sweating:   I thought it was a newbie mistake.  I'd be interesting to know if you can get around that horizontal scroll for the list.  I prefer the list over the edit box because it's less flicky.  What I meant is my mouse pointer tends to flicker when I move it to the edit box.

Now I kind of understand what the GuiCtrlSetLimit does.  I messed with it in the example script but didn't quite understand its functionality.

Link to comment
Share on other sites

I looked in the helpfile and it has an example of Horizontal Scroll (_GUICtrlListBox+AddString.au3).  That example script worked but the "$WS_HSCROLL" doesn't when it's being used with GuiCtrlSetData.  I think we have to call "_GUICtrlListBox_UpdateHScroll" for it to work.

:Edit:

Just tested it with your script and it works.  Be sure to add #include <GuiListBox.au3>

_GUICtrlListBox_UpdateHScroll ($log_label)

Thanks again for all your help Melba.

Edited by dreamzboy
Link to comment
Share on other sites

  • Moderators

dreamzboy,

Good spot - thanks for doing all the work. :thumbsup:

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

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