Jump to content

A Gui idea


Recommended Posts

Is there any way to improve the cpu usage of this:

;~ 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 by Nemcija

[url=www.vergessene-welt.de][/url]

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...