gormac Posted August 9, 2007 Share Posted August 9, 2007 This forum has been great for me in creating a tool I'm working on, but I've reached a sticking point that hopefully one of you guys out there can help with. I'm trying to create an on-screen-display that collects information from a program running in the background, and display it in large bold font, full screen. This information needs to update regularly (every 30 seconds or so). I seem to have cracked gathering the information and displaying it in the format I want, but it does not update correctly. Every loop a new GUI is created and overlaps the last one, rather than refreshing or replacing it. When this happens I cannot close the GUI without ending the process. I'm new to this, so not sure whether a GUI is even the right way to display what I want - any help? expandcollapse popup#include <GUIConstants.au3> While 1 ;~ Checks if the source program is running and activates If WinExists("External Data Source") = 0 Then MsgBox(0, "", "External Data Source is not running") Exit EndIf WinActivate("External Data Source", "") ; Prompts an export of data ControlSend("External Data Source", "","", "{ALT}") ControlSend("External Data Source", "","", "{RIGHT}") ControlSend("External Data Source", "","", "{DOWN 3}") ControlSend("External Data Source", "","", "{ENTER}") ;~ Finds each bit of info on the clipboard, and pulls out the stats I need $Clip = ClipGet() $STAT1pos = StringInStr($Clip, " ",0, 13,) $STAT2pos = StringInStr($Clip, " ",0, 14,) $STAT3pos = StringInStr($Clip, " ",0, 15,) $STAT4pos = StringInStr($Clip, " ",0, 16,) $STAT5pos = StringInStr($Clip, " ",0, 17,) $STAT1 = StringMid($Clip, $STAT1pos+1, $STAT2pos-$STAT1pos-1) $STAT2 = StringMid($Clip, $STAT2pos+1, $STAT3pos-$STAT2pos-1) $STAT3 = StringMid($Clip, $STAT3pos+1, $STAT4pos-$STAT3pos-1) $STAT4 = StringMid($Clip, $STAT4pos+1, $STAT5pos-$STAT4pos-1) ;~ Some definitions for the GUI $GUIWidth = @DesktopWidth $GUIHeight = @DesktopHeight $GUIColour = 0x8b8b83 $GUIFont="Arial" $GUIFontSize= $GUIHeight / 35 ;~ Displays the results ~ Create a GUI GUICreate("Full Screen Display",$GUIWidth,$GUIHeight,-1,-1,$WS_POPUPWINDOW,$WS_EX_TOPMOST) GUISetBkColor ($GUIColour) GUISetFont ($GUIFontSize, 400, $GUIFont) ;~ Create the Close button, and activate GUI Opt("GUICoordMode",1) $CloseButton = GUICtrlCreateButton ("Close", $GUIWidth-40, $GUIHeight-20, 40, 20,) GUICtrlSetFont ($CloseButton, 8, 400, $GUIFont) GUICtrlSetBkColor ($CloseButton, $GUIColour) GUISetState () ;~ Insert text into the GUI $ColumnWidth = $GUIWidth / 6 $RowHeight = $GUIHeight / 10 GUICtrlCreateLabel ("1st stat to display", $ColumnWidth * 1 , $RowHeight * 1) GUICtrlCreateLabel ("2nd stat to display", $ColumnWidth * 1 , $RowHeight * 2) GUICtrlCreateLabel ("3rd stat to display", $ColumnWidth * 1 , $RowHeight * 3) GUICtrlCreateLabel ("4th stat to display", $ColumnWidth * 1 , $RowHeight * 4) GUICtrlCreateLabel ($STAT1, $ColumnWidth * 3 , $RowHeight * 1) GUICtrlCreateLabel ($STAT2, $ColumnWidth * 3 , $RowHeight * 2) GUICtrlCreateLabel ($STAT3, $ColumnWidth * 3 , $RowHeight * 3) GUICtrlCreateLabel ($STAT4, $ColumnWidth * 3 , $RowHeight * 4) Sleep(5000) WEnd Link to comment Share on other sites More sharing options...
Zedna Posted August 9, 2007 Share Posted August 9, 2007 I corrected only GUI related stuff not your external logic. Note that WinActivate() inside loop is incorrect - comment this line and in ControlSend() specify ClassNameNN parameter. expandcollapse popup#include <GUIConstants.au3> Opt("GUICoordMode",1) ;~ Some definitions for the GUI $GUIWidth = @DesktopWidth $GUIHeight = @DesktopHeight $GUIColour = 0x8b8b83 $GUIFont="Arial" $GUIFontSize= $GUIHeight / 35 $ColumnWidth = $GUIWidth / 6 $RowHeight = $GUIHeight / 10 ;~ Displays the results ~ Create a GUI GUICreate("Full Screen Display",$GUIWidth,$GUIHeight,-1,-1,$WS_POPUPWINDOW,$WS_EX_TOPMOST) GUISetBkColor ($GUIColour) GUISetFont ($GUIFontSize, 400, $GUIFont) ;~ Create the Close button, and activate GUI $CloseButton = GUICtrlCreateButton ("Close", $GUIWidth-40, $GUIHeight-20, 40, 20) GUICtrlSetFont ($CloseButton, 8, 400, $GUIFont) GUICtrlSetBkColor ($CloseButton, $GUIColour) GUICtrlCreateLabel ("1st stat to display", $ColumnWidth * 1 , $RowHeight * 1) GUICtrlCreateLabel ("2nd stat to display", $ColumnWidth * 1 , $RowHeight * 2) GUICtrlCreateLabel ("3rd stat to display", $ColumnWidth * 1 , $RowHeight * 3) GUICtrlCreateLabel ("4th stat to display", $ColumnWidth * 1 , $RowHeight * 4) $label1 = GUICtrlCreateLabel ('', $ColumnWidth * 3 , $RowHeight * 1) $label2 = GUICtrlCreateLabel ('', $ColumnWidth * 3 , $RowHeight * 2) $label3 = GUICtrlCreateLabel ('', $ColumnWidth * 3 , $RowHeight * 3) $label4 = GUICtrlCreateLabel ('', $ColumnWidth * 3 , $RowHeight * 4) GUISetState () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Or $msg = $CloseButton Then ExitLoop ;~ Checks if the source program is running and activates If WinExists("External Data Source") = 0 Then MsgBox(0, "", "External Data Source is not running") Exit EndIf WinActivate("External Data Source", "") ; Prompts an export of data ControlSend("External Data Source", "","", "{ALT}") ControlSend("External Data Source", "","", "{RIGHT}") ControlSend("External Data Source", "","", "{DOWN 3}") ControlSend("External Data Source", "","", "{ENTER}") ;~ Finds each bit of info on the clipboard, and pulls out the stats I need $Clip = ClipGet() $STAT1pos = StringInStr($Clip, " ",0, 13) $STAT2pos = StringInStr($Clip, " ",0, 14) $STAT3pos = StringInStr($Clip, " ",0, 15) $STAT4pos = StringInStr($Clip, " ",0, 16) $STAT5pos = StringInStr($Clip, " ",0, 17) $STAT1 = StringMid($Clip, $STAT1pos+1, $STAT2pos-$STAT1pos-1) $STAT2 = StringMid($Clip, $STAT2pos+1, $STAT3pos-$STAT2pos-1) $STAT3 = StringMid($Clip, $STAT3pos+1, $STAT4pos-$STAT3pos-1) $STAT4 = StringMid($Clip, $STAT4pos+1, $STAT5pos-$STAT4pos-1) GUICtrlSetData ($label1, $STAT1) GUICtrlSetData ($label2, $STAT1) GUICtrlSetData ($label3, $STAT1) GUICtrlSetData ($label4, $STAT1) WEnd Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
smashly Posted August 9, 2007 Share Posted August 9, 2007 (edited) Hi, From a brief look at your script , it looks like your creating your gui and labels over and over again. This is due to you have your Gui and Labels inside the main While 1 loop. So While 1 you are recreating the Gui and Labels over and over and over and over and over and over........ again and again and again and again.... until While doesn't equal 1. Maybe try creating your Gui and Labels before the While 1 loop then in the While 1 loop use GuiCtrlSetData() to set the info in the already created labels instead of recreating the labels over and over again. Good luck and Cheers Edit: I was to slow as usual , Zenda has the answer Edited August 9, 2007 by smashly Link to comment Share on other sites More sharing options...
Zedna Posted August 9, 2007 Share Posted August 9, 2007 Edit: I was to slow as usual , Zenda has the answerI'm Zedna and not Zenda !!!You are not the first with this my nickname "improvement" here.I know in english it sound like a crap but in Czech it's OK and it's based on my real name so change will not happen. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
gormac Posted August 9, 2007 Author Share Posted August 9, 2007 Thanks Zedna, Zenda and smashley You've helped me out of a jam. I knew one of the forum gurus would point me in the right direction. Link to comment Share on other sites More sharing options...
smashly Posted August 10, 2007 Share Posted August 10, 2007 Sorry about that Zedna :"> How rude of me , after seeing your helpful post for the past year and I still got your name wrong , shame on me. Will make sure I get it correct next time All the bestCheers. Link to comment Share on other sites More sharing options...
Zedna Posted August 10, 2007 Share Posted August 10, 2007 Sorry about that Zedna :"> How rude of me , after seeing your helpful post for the past year and I still got your name wrong , shame on me. Will make sure I get it correct next time All the bestCheers.OK. I trust your promise Cheers. Resources UDF ResourcesEx UDF AutoIt Forum Search 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