DeLorean Posted July 31, 2013 Share Posted July 31, 2013 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 31, 2013 Moderators Share Posted July 31, 2013 (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. M23P.S. Welcome to the AutoIt forum, by the way. Edited July 31, 2013 by Melba23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
DeLorean Posted July 31, 2013 Author Share Posted July 31, 2013 Thanks for the quick reply! I'll give this a try, but I may be back for some more help... I'm very new! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 31, 2013 Moderators Share Posted July 31, 2013 (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! M23P.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 July 31, 2013 by Melba23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
DeLorean Posted July 31, 2013 Author Share Posted July 31, 2013 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. expandcollapse popup;;;;;;;;;;;;;;;;; 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() Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted July 31, 2013 Moderators Solution Share Posted July 31, 2013 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now