Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

GUI refresh


  • Please log in to reply
6 replies to this topic

#1 gormac

gormac

    Seeker

  • New Members
  • 2 posts

Posted 09 August 2007 - 12:25 PM

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?

Plain Text         
#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








#2 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,679 posts

Posted 09 August 2007 - 12:57 PM

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.

AutoIt         
#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


#3 smashly

smashly

  • Active Members
  • PipPipPipPipPipPip
  • 1,636 posts

Posted 09 August 2007 - 12:59 PM

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 by smashly, 09 August 2007 - 01:00 PM.


#4 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,679 posts

Posted 09 August 2007 - 01:11 PM

Edit: I was to slow as usual , Zenda has the answer


I'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 :P and it's based on my real name so change will not happen.

#5 gormac

gormac

    Seeker

  • New Members
  • 2 posts

Posted 09 August 2007 - 02:53 PM

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.

#6 smashly

smashly

  • Active Members
  • PipPipPipPipPipPip
  • 1,636 posts

Posted 10 August 2007 - 05:37 AM

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 :P

All the best
Cheers.

#7 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,679 posts

Posted 10 August 2007 - 10:04 PM

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


OK. I trust your promise :P

Cheers.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users