ChrisL Posted July 25, 2007 Share Posted July 25, 2007 (edited) Hi I'm trying to make a status dot that when something is happening the dot is red and when it's idle it is green however I'm not having much luck, the script below you can see the label change but not the dot. can someone show me whats wrong thanks #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 349, 152, 193, 115) $Graphic1 = GUICtrlCreateGraphic(8, 8, 49, 49) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x00ff00,0x00ff00) GUICtrlSetGraphic(-1,$GUI_GR_ELLIPSE, 5,5, 10,10) $label = GuiCtrlCreateLabel("Green",20,60,200,20) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### For $i = 1 to 5 Sleep (2000) Switch $i Case 1,3,5 GUICtrlSetGraphic($Graphic1,$GUI_GR_COLOR, 0xff0000,0xff0000) GUICtrlSetData($label,"Red") Case Else GUICtrlSetGraphic($Graphic1,$GUI_GR_COLOR, 0x00ff00,0x00ff00) GUICtrlSetData($label,"Green") Endswitch Next Sleep (2000) Edited July 25, 2007 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Zedna Posted July 25, 2007 Share Posted July 25, 2007 Try explicit control name instead of -1 in GUICtrlSetGraphic() #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 349, 152, 193, 115) $Graphic1 = GUICtrlCreateGraphic(8, 8, 49, 49) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x00ff00,0x00ff00) GUICtrlSetGraphic(-1,$GUI_GR_ELLIPSE, 5,5, 10,10) $label = GuiCtrlCreateLabel("Green",20,60,200,20) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### For $i = 1 to 5 Sleep (2000) Switch $i Case 1,3,5 GUICtrlSetGraphic($Graphic1,$GUI_GR_COLOR, 0xff0000,0xff0000) GUICtrlSetData($label,"Red") Case Else GUICtrlSetGraphic($Graphic1,$GUI_GR_COLOR, 0x00ff00,0x00ff00) GUICtrlSetData($label,"Green") Endswitch Next Sleep (2000) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ChrisL Posted July 25, 2007 Author Share Posted July 25, 2007 Try explicit control name instead of -1 in GUICtrlSetGraphic() #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 349, 152, 193, 115) $Graphic1 = GUICtrlCreateGraphic(8, 8, 49, 49) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x00ff00,0x00ff00) GUICtrlSetGraphic(-1,$GUI_GR_ELLIPSE, 5,5, 10,10) $label = GuiCtrlCreateLabel("Green",20,60,200,20) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### For $i = 1 to 5 Sleep (2000) Switch $i Case 1,3,5 GUICtrlSetGraphic($Graphic1,$GUI_GR_COLOR, 0xff0000,0xff0000) GUICtrlSetData($label,"Red") Case Else GUICtrlSetGraphic($Graphic1,$GUI_GR_COLOR, 0x00ff00,0x00ff00) GUICtrlSetData($label,"Green") Endswitch Next Sleep (2000) Sorry I edited the first post because I later added the label to show so -1 was wrong, I edited my first post a few minutes ago. but it doesn't work like that either! [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
ChrisL Posted July 25, 2007 Author Share Posted July 25, 2007 This is the only way I can get it to work, it seems a bit extreem to delete the graphic and recreate it though Is there a better way? #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 349, 152, 193, 115) $Graphic1 = GUICtrlCreateGraphic(8, 8, 49, 49) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x00ff00,0x00ff00) GUICtrlSetGraphic(-1,$GUI_GR_ELLIPSE, 5,5, 10,10) $label = GuiCtrlCreateLabel("Green",20,60,200,20) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### For $i = 1 to 5 Sleep (2000) Switch $i Case 1,3,5 $Graphic1 = GUICtrlCreateGraphic(8, 8, 49, 49) GUICtrlSetGraphic($Graphic1,$GUI_GR_COLOR, 0xff0000,0xff0000) GUICtrlSetGraphic(-1,$GUI_GR_ELLIPSE, 5,5, 10,10) GUICtrlSetState(-1,$Gui_Show) GUICtrlSetData($label,"Red") Case Else $Graphic1 = GUICtrlCreateGraphic(8, 8, 49, 49) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x00ff00,0x00ff00) GUICtrlSetGraphic(-1,$GUI_GR_ELLIPSE, 5,5, 10,10) GUICtrlSetState(-1,$Gui_Show) GUICtrlSetData($label,"Green") Endswitch Next Sleep (2000) [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Zedna Posted July 25, 2007 Share Posted July 25, 2007 Answer is GUICtrlSetGraphic($Graphic1,$GUI_GR_REFRESH) #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 349, 152, 193, 115) $Graphic1 = GUICtrlCreateGraphic(8, 8, 49, 49) GUICtrlSetGraphic($Graphic1,$GUI_GR_COLOR, 0x00ff00,0x00ff00) GUICtrlSetGraphic($Graphic1,$GUI_GR_ELLIPSE, 5,5, 10,10) $label = GuiCtrlCreateLabel("Green",20,60,200,20) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### For $i = 1 to 5 Sleep (2000) Switch $i Case 1,3,5 GUICtrlSetGraphic($Graphic1,$GUI_GR_COLOR, 0xff0000,0xff0000) GUICtrlSetGraphic($Graphic1,$GUI_GR_ELLIPSE, 5,5, 10,10) GUICtrlSetGraphic($Graphic1,$GUI_GR_REFRESH) GUICtrlSetData($label,"Red") Case Else GUICtrlSetGraphic($Graphic1,$GUI_GR_COLOR, 0x00ff00,0x00ff00) GUICtrlSetGraphic($Graphic1,$GUI_GR_ELLIPSE, 5,5, 10,10) GUICtrlSetGraphic($Graphic1,$GUI_GR_REFRESH) GUICtrlSetData($label,"Green") Endswitch Next Sleep (2000) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ChrisL Posted July 25, 2007 Author Share Posted July 25, 2007 Thank you again for your reply, I do have an however..... That is drawing the graphic over and over the top rather than changing the colour of the original graphic. The graphic is very small so the affect is not too bad but it does cause a memory leak over several thousand changes, where as the crude way of deleting the graphic control and recreating it rather than drawing on top doesn't cause a leak. Anyone know is there a way to change the colour of the original graphic without either drawing on top or re-creating the whole contro? [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire 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