In its original use, the scrolling message was only looped 10-100 times by the user before the program was ended. In its new implementation, it will be running on a machine interface that operates nearly 24/7, 365.
My method of achieving the "scrolling" look is to shift the status messages down as a new message arrives, while slowly decreasing the height of the last message. If i understand correctly, these shrunken text elements still exist, they just have a height of 0.
My question is; if i let these messages scroll for days on end, will i run into a memory problem? Mentally i'm telling myself that there will be an endless pile of (invisible) text elements at the bottom of my status window with a height of 0. At some point this number will accumulate so large that the program will crash. If not, i'll surely run into a problem when Static1 accumulates into Static9223372036854775807 (0x7FFFFFFFFFFFFFFF).
I saw in the help file that GuiControl, Delete is not implemented yet. My other though was to "re-use" each of the oldest text elements as the newest element rather than creating a new one. As a last resort, i could destroy the GUI on a timer and re-create it every so often (i'd rather not do this).
The code attached below is a raw form of my GUI from my "play area" - it's REALLY messy and contains a bunch of fluff that isn't used here but is in my original program., sorry. It should illustrate my point though... Do a Ctrl+F on "Height6" to see the area where i'm shrinking the height to make the last message "disappear".
Press Ctrl+Alt+1,2,3 to see the messages and how they scroll.
Any thoughts?
Code: Select all
#Persistent ;(* Keep script running *)
#NoEnv ;(* Handle empty variables *)
SetBatchLines -1 ;(* Run script at max speed *)
ListLines Off ;(* Only show most recent executed lines in history *)
DetectHiddenText, ON ;(* Hidden text omitted from search criteria *)
if(!(iStringCnt >= 0))
iStringCnt := 5
if(!(iPrintStringIndex >= 0))
iPrintStringIndex := 0
if(!(iPrintStringCnt >= 0))
iPrintStringCnt := 0
;Gui, New, +AlwaysOnTop -Caption, Collation Helper
Gui +AlwaysOnTop -Caption
;(* Program Status Header *)
Gui +LastFound
Gui, Font, S20 C0099CC W700, Verdana
Gui, Add, Text, x5 y0 w236 h32, Program Status
;(* Status Window Texts *)
Gui, Font, S12 CD2D2D2 W400, Verdana
Gui, Add, Text, x10 y35 w113 h18, Label Printing
Gui, Add, Text, x230 y35 w150 h20, Data Gathering
;(* Status Window Group Boxes *)
Gui, Add, GroupBox, x10 y45 w200 h85,
Gui, Add, GroupBox, x230 y45 w200 h85,
;(* Window divider *)
Gui, Add, GroupBox, x-2 y-11 w454 h161
;(* Machine Status *)
Gui, Font, S20 C0099CC W700, Verdana
Gui, Add, Text, x5 y150 w236 h32, Machine Status
Gui, Font, S18 C222226 W400, Verdana
Gui, Add, Text, x125 y240 w200 h32, Coming soon...
;Gui, Font, S8 C6E6E78 W400, Verdana
;Gui, Add, Text, x15 y56 w190 h13, testg
;Gui, Font, S12 C0099CC W100, Wingdings
;Gui, Add, Text, x15 y150 w190 h13, pon
;Gui, Add, GroupBox, x-2 y-11 w243 h300
Gui, Color, 0x000000
;Gui, Add, Text, x0 y0 w230 h14, test123 ;(* Add newest message at first position *)
Gui, Show, w440 h375, Collation Helper
return
GuiClose:
ExitApp
;(* Shift window up *)
^!Up::
WinGetPos, X, Y, , , Collation Helper
WinMove, Collation Helper,,, Y-5
return
;(* Shift window down *)
^!Down::
WinGetPos, X, Y, , , Collation Helper
WinMove, Collation Helper,,, Y+5
return
;(* Shift window right *)
^!Left::
WinGetPos, X, Y, , , Collation Helper
WinMove, Collation Helper,,X-5,
return
;(* Shift window left *)
^!Right::
WinGetPos, X, Y, , , Collation Helper
WinMove, Collation Helper,,X+5,
return
^!1::
sPrintStatus := "Waiting for start of next spool..."
iPrintStatusID := 1
UpdatePrintStatus()
return
^!2::
sPrintStatus := "Message 2"
iPrintStatusID := 2
UpdatePrintStatus()
return
^!3::
sPrintStatus := "Message 3"
iPrintStatusID := 3
UpdatePrintStatus()
return
;(* Update Turck Status Messages ---------------------------------------------------------------------------------------------------------------------------------------------- *)
UpdatePrintStatus() ;(* Update GUI status message function *)
{ ;(* *)
Global sPrintStatus ;(* Pull first status message as global *)
Global sPrintStatus2 ;(* Pull second status message as global *)
Global sPrintStatus3 ;(* Pull third status message as global *)
Global sPrintStatus4 ;(* Pull third status message as global *)
Global sPrintStatus5 ;(* Pull third status message as global *)
Global iPrintStatusID ;(* Pull status ID as global *)
Global iPrintStatusID2 ;(* Pull previous status ID as global *)
Global iStringCnt ;(* Pull string total count as global *)
Global iPrintStringIndex ;(* Pull Turck string index as global *)
Global iPrintStringCnt ;(* Pill Turck string count as global *)
Global iPrintStringIndex2 ;(* Pull Turck 2nd string index as global *)
global iPrintStringIndex3 ;(* Pull Turck 3rd string index as global *)
global iPrintStringIndex4 ;(* Pull Turck 3rd string index as global *)
global iPrintStringIndex5 ;(* Pull Turck 3rd string index as global *)
if(iPrintStringIndex = 0) ;(* Turck string index = 0? *)
{ ;(* *)
if(iStringCnt > 0) ;(* Total string count > 0? *)
iPrintStringIndex := iStringCnt ;(* Set Turck string index = total string count *)
} ;(* *)
if(TRUE) ;(* Is the Turck update still required? *)
{ ;(* *)
if(iPrintStatusID != iPrintStatusID2) ;(* Has the status ID changed from the previous? *)
{ ;(* *)
;(* Shift GUI status messages down to make room for newest message ------------------------------------------------------------------------------------------------ *)
Loop, 14 ;(* Loop for 14 iterations *)
{ ;(* *)
if (iPrintStringCnt >= 2) ;(* Two or more pre-existing status messages? *)
{ ;(* *)
iYCoord3 := (69 + A_Index) ;(* Increase message 3 Y coord. by loop index *)
sYCoord3 := % "y" . iYCoord3 ;(* Assemble message 3 Y coord. string *)
GuiControl, Move, % "Static" iPrintStringIndex2, x15, %sYcoord3% ;(* Move 3rd message to new Y coord *)
} ;(* *)
if (iPrintStringCnt >= 3) ;(* Two or more pre-existing status messages? *)
{ ;(* *)
iYCoord4 := (84 + A_Index) ;(* Increase message 3 Y coord. by loop index *)
sYCoord4 := % "y" . iYCoord4 ;(* Assemble message 3 Y coord. string *)
GuiControl, Move, % "Static" iPrintStringIndex3, x15, %sYcoord4% ;(* Move 3rd message to new Y coord *)
} ;(* *)
if (iPrintStringCnt >= 4) ;(* Two or more pre-existing status messages? *)
{ ;(* *)
iYCoord5 := (99 + A_Index) ;(* Increase message 3 Y coord. by loop index *)
sYCoord5 := % "y" . iYCoord5 ;(* Assemble message 3 Y coord. string *)
GuiControl, Move, % "Static" iPrintStringIndex4, x15, %sYcoord5% ;(* Move 3rd message to new Y coord *)
} ;(* *)
if (iPrintStringCnt >= 5) ;(* Three or more pre-existing status messages? *)
{ ;(* *)
iYCoord6 := (114 + A_Index) ;(* Increase message 4 Y coord. by loop index *)
sYCoord6 := % "y" . iYCoord6 ;(* Assemble message 4 Y coord. string *)
sHeight6 := % "h" . (14 - A_Index) ;(* Decrease message 4 height *)
GuiControl, Move, % "Static" iPrintStringIndex5, x15, %sHeight6%, %sYcoord6% ;(* Move 4th message to new Y coord. *)
} ;(* *)
if(iPrintStringCnt >= 1) ;(* One or more pre-existing status messages? *)
{ ;(* *)
iYCoord2 := (55 + A_Index) ;(* Increase message 2 Y coord. by loop index *)
sYCoord2 := % "y" . iYCoord2 ;(* Assemble message 2 Y coord. string *)
GuiControl, Move, % "Static" iPrintStringIndex, x15, %sYcoord2% ;(* Move 2nd message to new Y coord. *)
} ;(* *)
Sleep, 1 ;(* Sleep 1ms so shift isn't instantaneous *)
} ;(* *)
if(iPrintStringCnt >= 1) ;(* One or more pre-existing status messages? *)
{
Gui, Font, S8 C6E6E78 W400, Verdana
GuiControl, Font, % "Static" iPrintStringIndex
}
if(iPrintStringCnt >= 2) ;(* One or more pre-existing status messages? *)
{
Gui, Font, S8 C505058 W400, Verdana
GuiControl, Font, % "Static" iPrintStringIndex2
}
if(iPrintStringCnt >= 3) ;(* One or more pre-existing status messages? *)
{
Gui, Font, S8 C37373D W400, Verdana
GuiControl, Font, % "Static" iPrintStringIndex3
}
if(iPrintStringCnt >= 4) ;(* One or more pre-existing status messages? *)
{
Gui, Font, S8 C222226 W400, Verdana
GuiControl, Font, % "Static" iPrintStringIndex4
}
if(iPrintStringCnt >=5)
GuiControl, Hide, % "Static" iPrintStringIndex5
;(* --------------------------------------------------------------------------------------------------------------------------------------------------------------- *)
Gui, Font, S8 C0099CC W400, Verdana
Gui, Add, Text, x15 y56 w190 h13, %sPrintStatus%
;(* Re Index existing messages for next function call ------------------------------------------------------------------------------------------------------------- *)
sPrintStatus5 := sPrintStatus4 ;(* Copy 2nd string to 3rd string *)
sPrintStatus4 := sPrintStatus3 ;(* Copy 2nd string to 3rd string *)
sPrintStatus3 := sPrintStatus2 ;(* Copy 2nd string to 3rd string *)
sPrintStatus2 := sPrintStatus ;(* Copy 1st string into 2nd string *)
iPrintStatusID2 := iPrintStatusID ;(* Copy current string ID to previous string ID *)
iPrintStringIndex5 := iPrintStringIndex4 ;(* Copy Turck index 2 to index 3 *)
iPrintStringIndex4 := iPrintStringIndex3 ;(* Copy Turck index 2 to index 3 *)
iPrintStringIndex3 := iPrintStringIndex2 ;(* Copy Turck index 2 to index 3 *)
iPrintStringIndex2 := iPrintStringIndex ;(* Copy Turck index 1 to index 2 *)
iStringCnt += 1 ;(* Increase total string count *)
iPrintStringIndex := iStringCnt ;(* Copy total string count to Turck index 1 *)
iPrintStringCnt += 1 ;(* INcrease turck string count *)
;(* --------------------------------------------------------------------------------------------------------------------------------------------------------------- *)
} ;(* *)
} ;(* *)
return ;(* Return to program *)
} ;(* *)