Nemcija Posted October 9, 2006 Share Posted October 9, 2006 (edited) Is there any way to improve the cpu usage of this: expandcollapse popup;~ Includes #include <Guiconstants.au3> ;~ opts ;~ funcs Func terminate() Exit EndFunc ;~ hotkeys HotKeySet("{ESC}","terminate") ;~ vars $sli = 0 $br = 100 $c_a = 0xff0000 $c_i = 0xffffff ;~ Gui GUICreate("GraphSlider",$br+10,30) dim $grx[$br+1] for $i = 1 to $br $grx[$i] = GUICtrlCreateGraphic(5+$i,5,1,20) GUICtrlSetBkColor(-1,$c_i) Next GUISetState(@SW_SHOW) ;~ runtime While 1 $msg = GUIGetMsg() for $i = 1 to $br If $msg = $grx[$i] Then if $sli < $i Then for $y = 1 to $br if $y > $i Then GUICtrlSetBkColor($grx[$y],$c_i) Else GUICtrlSetBkColor($grx[$y],$c_a) EndIf Next Else for $y = 1 to $br if ($br-$y) > $i Then GUICtrlSetBkColor($grx[(($br+1)-$y)],$c_i) Else GUICtrlSetBkColor($grx[(($br+1)-$y)],$c_a) EndIf Next EndIf $sli = $i EndIf Next WEnd ;~ end Is there a gui object which is similar? (but FASTER) ^^ greetings, Nemcija Edited October 9, 2006 by Nemcija [url=www.vergessene-welt.de][/url] Link to comment Share on other sites More sharing options...
Valik Posted October 9, 2006 Share Posted October 9, 2006 How is this a topic appropriate for the "Idea Lab"? Moved to Support where it belongs. Link to comment Share on other sites More sharing options...
zcoacoaz Posted October 10, 2006 Share Posted October 10, 2006 uhhh if you don't already know, you need to add in sleeps like this: While 1 $msg = GUIGetMsg() for $i = 1 to $br If $msg = $grx[$i] Then if $sli < $i Then for $y = 1 to $br if $y > $i Then GUICtrlSetBkColor($grx[$y],$c_i) Else GUICtrlSetBkColor($grx[$y],$c_a) EndIf Next Else for $y = 1 to $br if ($br-$y) > $i Then GUICtrlSetBkColor($grx[(($br+1)-$y)],$c_i) Else GUICtrlSetBkColor($grx[(($br+1)-$y)],$c_a) EndIf Next EndIf $sli = $i EndIf Sleep ( 1 ) Next WEnd Adjustments might need to be made if it decreases performance a ton [font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font] Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 10, 2006 Share Posted October 10, 2006 (edited) Remarks This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU. From the help file page for GUIGetMsg( [advanced] ). Edit: fixed quite, missed line feed Edited October 10, 2006 by Icekirby1 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