Jump to content

ProgressBar Color


ScriptMoron
 Share

Recommended Posts

I need to be able to change from the current green color to red, I am using the progress bar as a warning of logout and it has to be obnoxious or it will be ignored. Here is the current code, the color change works fine for the text. yes, I know it is ugly, it needs to be.

Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=J:\icons\misc\COrec34.ico
#AutoIt3Wrapper_outfile=10min-timeout.exe
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
TraySetState(2) 

#include <Timers.au3>
#include <GuiConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>

$wait = 1000; wait 1s for next progressstep
$warningTimeout = 60; how much time user has to deactivate inactivity timeout
$idleTimeout = 600; how much idle time before warning kicks in
$expired = False
$width = @DesktopWidth/4
$height = @DesktopHeight/4


Do
    $iIdleTime = _Timer_GetIdleTime()
    ConsoleWrite("Debug:  Unconverted = " & $iIdleTime & @LF)

    If $iIdleTime >= ($idleTimeout * 1000) Then
        $expired = True

        GUICreate("Fast Login Inactivity Timeout", 720, 300,$width,$height,$WS_DLGFRAME,$WS_EX_TOPMOST)
        $font = "Arial"
        GUISetFont (18, 400, -1, $font) 
                
        $progressText = GUICtrlCreateLabel("",5,200,410,225); first cell 70 width
        $progressBar = GUICtrlCreateProgress(5, 10, 700, 190, $PBS_SMOOTH)
        GUICtrlSetColor($progressText, 0xE00F11)
                
        GUISetState()
        
        For $i = 0 To $warningTimeout
            GUICtrlSetData($progressBar, (100 - ($i*(100/$warningTimeout))))
            GUICtrlSetData($progressText, $warningTimeout - $i & " seconds remaining before logout")
            
            $iIdleTime = _Timer_GetIdleTime()
            ConsoleWrite("Debug:  Unconverted = " & $iIdleTime & @LF)
            If $iIdleTime < ($idleTimeout * 1000) Then
                GUIDelete()
                $expired = False
                ExitLoop
            EndIf
            
            Sleep($wait)
        Next
    Else
        Sleep (1000);
    EndIf
    
Until $expired == True
Link to comment
Share on other sites

I need to be able to change from the current green color to red, I am using the progress bar as a warning of logout and it has to be obnoxious or it will be ignored. Here is the current code, the color change works fine for the text. yes, I know it is ugly, it needs to be.

GUICtrlSetColor($progressBar,0xFF0000)

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

I guess your careful search for "Progressbar color" didn't turn this one up

#455216

Edit: This has been asked and answered several times and I'm sure a search would turn up several more. The trick is in setting the windows theme. You can't change the color with the XP theme.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Hey, I have got a good idea! Give me a few minutes...

EDIT: here you go!

; Example by RomanK: How to make a coloured progress bar without the Progressbar control.

#include <GUIConstantsEx.au3>

GUICreate("Progress bar fake", 400, 100)

$progress_frame = GUICtrlCreateLabel("", 10, 10, 380, 35, 0x12)

$progress = GUICtrlCreateLabel("", 11, 11, 0, 32); x = 11 and y = 11 because I thought it looks better with a visible frame.
GUICtrlSetBkColor(-1, 0xFF0000)

$progress_percentage = GUICtrlCreateLabel("", 10, 21, 380, 20, 0x01); y = 21 to make the percentage vertically centered.
GUICtrlSetBkColor(-1, -2); $GUI_BKCOLOR_TRANSPARENT

$width = 0

GUISetState()

While 1
    If $width < 380 Then
        Sleep(50); Speed rate the Progress bar changes with. Of course you wouldn't use Sleep in a real program, as the GUI is no more responding.
        $width += 1
        GUICtrlSetPos($progress, 11, 11, $width)
        GUICtrlSetData($progress_percentage, "  " & Round($width / 380 * 100, 1) & "%" )
    ; Spaces added because it wasn't centered. Round() makes it as many decimal places as you want. Abs() for absolute numbers without decimals.
    Else
        ExitLoop
    EndIf
WEnd

Exit

; Code Ending

btw you can also use GUIGetMsg() in the loop, but then Sleep is getting inaccurate and the progress bar slows down and accelarates sometimes instead of increasing constantly.

regards,

RomanK

PS. I will make a UDF of this, because it's fun^^

Edited by RomanK
[font="Courier New"]http://RomanK.hondadesigns.com[/font]
Link to comment
Share on other sites

Thank you, these are great ideas .. My search was Progress bar not progressbar , should know better to search on all options. I will adjust my code to try out these options. thank you again

searching for progress*bar*color should return the right results as well.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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