Sign in to follow this  
Followers 0
DeLorean

Vertical Scrolling Label: How to add lines on the fly?

6 posts in this topic

Through some other posts on this forum I was able to find the code for a vertical-scrolling label. I am trying to have a place for the user to see what my program is doing. For instance, at different points in the script I want it to say things like "Opening the program" and then once it gets to another part in my software say "Attempting to reposition window..." and then later say "Logging in" etc. Basically a debug/status window. My question is, with this scrolling label, how do I simply add a line at different points in my script?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GUIScrollBars_Ex.au3>
#include <StringSize.au3>

$sText = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
$aText_Info = _StringSize($sText, Default, Default, Default, "", 90)

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

GUISetState()

$hScroller = GUICreate("Scroller", 230, 480, 10, 10, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_MDICHILD, $hGUI)
$hLabel = GUICtrlCreateLabel($aText_Info[0], 0, 0, 183, $aText_Info[3])
GUISetState()

_GUIScrollbars_Generate ($hScroller, 0, $aText_Info[3])

While 1
   Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
         Exit
   EndSwitch 
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

DeLorean,

Personally I would use a read-only edit control rather than a label to create a log. Then all you need to do is add a line at the end of the current text and it scrolls automatically. :)

M23

P.S. Welcome to the AutoIt forum, by the way. :)

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

Thanks for the quick reply! I'll give this a try, but I may be back for some more help... I'm very new!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

DeLorean,

 

I may be back for some more help... I'm very new!

That is not a problem. If you show some effort (as you already have done) we will be delighted to assist. :)

Besides any new member who uses 2 of my UDFs in his first posted code certainly deserves a helping hand! :D

M23

P.S. When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unneccessarily. ;)

Edit: I see you already realised that! ;)

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

Hehe beat you to it! I have a second question if you're willing/have time to look! It seems that when notepad.exe is NOT opened any my script opens it, it will reposition it fine. However, when the window is ALREADY opened... it does not reposition it! Any idea why this is? I know I am getting into my RepositionWindow() function okay.

;;;;;;;;;;;;;;;;;   INCLUDES            ;;;;;;;;;;;;;;;;;
#include <GUIConstantsEx.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>

;;;;;;;;;;;;;;;;;   GLOBAL VARIABLES    ;;;;;;;;;;;;;;;;

; Enter the name of the executable file
Global $gFileName = 'notepad.exe'
Global $gWindowTitle = 'Untitled - Notepad'

; Initialize the GUI
Global $myedit, $msg
GUICreate("RunDSO",350,500,800,0) ; will create a dialog box that when displayed is centered
$myedit = GUICtrlCreateEdit("Please refrain from using the mouse or keyboard..." & @CRLF, 0,0,350,500,$ES_AUTOVSCROLL + $WS_VSCROLL)
Sleep(3000)
GUISetState()
Send("{END}")
GUICtrlSetData($myedit, "Initializing GUI... " & @CRLF, 1)
Sleep(1000)

; Check to see if the window is not already open, if it is not, open it
If WinExists($gWindowTitle) Then
   GUICtrlSetData($myedit, $gWindowTitle & " is already open " & @CRLF, 1)
   RepositionWindow()
ElseIf Not WinExists($gWindowTitle) Then
   GUICtrlSetData($myedit, $gWindowTitle & " not found open... opening now" & @CRLF, 1)
   RunWindow()
EndIf

; Where is the mouse?
Local $pos = MouseGetPos()
;MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])
Local $var = PixelGetColor(125, 125)
;MsgBox(0, "The decimal color is", $var)
;MsgBox(0, "The hex color is", Hex($var, 6))

;;;;;;;;;;;;;;;;;   OPEN THE APPLICATION        ;;;;;;;;;;;;;;;;;
Func RunWindow()
   Run($gFileName)
   RepositionWindow()
EndFunc

Func RepositionWindow()
   GUICtrlSetData($myedit, "RepositionWindow() function called" & @CRLF, 1)
   Sleep(1000)
   ; Activate the window and move it so we have the same starting point each time
   WinWaitActive($gWindowTitle)
   GUICtrlSetData($myedit, "Repositioning window..." & @CRLF, 1)
   WinMove($gWindowTitle,'',0,0)
   GUICtrlSetData($myedit, "Window repositioned" & @CRLF, 1)
EndFunc

; Run the GUI until the dialog is closed
 While 1
     $msg = GUIGetMsg()
     If $msg = $GUI_EVENT_CLOSE Then ExitLoop
 WEnd
 GUIDelete()

Share this post


Link to post
Share on other sites

DeLorean,

That is an easy one. :)

In the function you are waiting for the Notepad GUI to become active. If you have just created it then it is likely to be the active GUI - but if it is already created, the GUI created by your script is active, not Notepad. You can test this by clicking on the title bar of Notepad when nothing appears to be happening - it becomes active and the script continues. ;)

Add a WinActivate line to the function to ensure that the Notepad GUI is indeed active and then it will work as you expect. :)

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

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