Jump to content
Sign in to follow this  
E1M1

GUI labl color problem... && I need ur help about blend(ing) from Green to Red

Recommended Posts

E1M1

Sorry for my bad english.

Hi How I must change my script? 1)I want "Time to action:" Always be in red color 2) I want "TIME" change it's color in every second, and I want It go from green to red(it should look like Health bar that changes it's color when value decreases), but instead of RGB my autoit uses BGR, how I could force autoit use RGB system? Why "Time to action:" is in black color if I told it to be Red?

I also wanna calculate color change amount, but it seems not working, so I need some suggestions about that too.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$time = 5*60
$R = 0
$G = 255
$step = $time / 255
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Action", 440, 50, 0, 0,0x96000000,0x00000080)
GUISetBkColor(0xFFFFFF,$Form1)
$Label1 = GUICtrlCreateLabel("Time to action:", 0, 8, 820, 50)
GUICtrlSetFont(-1, 24, 800, 0, "Courier New")
GUICtrlSetColor($Label1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("TIME", 360, 8, 75, 50)
GUICtrlSetFont(-1, 24, 800, 0, "Courier New")
GUICtrlSetColor(-1, "0x"&Hex($R,2)&Hex($G,2)&00)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;~ For $i = 1 To 96
;~  WinSetTrans("Arvuti_sulgemine","",255 - $i)
;~  Sleep(50)
;~ Next

While 1
Sleep(1000)
;~ MsgBox(1,hex($R,2),Hex($G,2))
$R = $R + $step
$G = $G - $step
$time = $time - 1
$text = Int($time / 60)
GUICtrlSetData($Label2,$text&":"&$time - ($text * 60 ))
GUICtrlSetColor($Label2,"0x"&hex($R,2)&Hex($G,2)&00)
WEnd
Edited by E1M1

edited

Share this post


Link to post
Share on other sites
Yashied

Try this.

GUICtrlSetColor($Label2, BitShift($R, -16) + BitShift($G, -8))

EDIT: If we look at your example you had to write down the following way.

GUICtrlSetColor($Label2, "0x" & Hex($R, 2) & Hex($G, 2) & "00")

Edited by Yashied

Share this post


Link to post
Share on other sites
E1M1

Ok now I need help with that color step calculator , it gets red when the time is about 1:20 and then ig gets back to green. how to avoid that?

Why is "Time to action:" in black color?

Edit: I had never used BitShift() in autoit GUI-s It walways worked with out it, why it dont work at this time?

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$time = 5*60
$R = 0
$G = 255
$step = $time / 255
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Action", 440, 50, 0, 0,0x96000000,0x00000080)
GUISetBkColor(0xFFFFFF,$Form1)
$Label1 = GUICtrlCreateLabel("Time to action:", 0, 8, 820, 50)
GUICtrlSetFont(-1, 24, 800, 0, "Courier New")
GUICtrlSetColor($Label1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("TIME", 360, 8, 75, 50)
GUICtrlSetFont(-1, 24, 800, 0, "Courier New")
GUICtrlSetColor(-1, "0x"&Hex($R,2)&Hex($G,2)&00)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;~ For $i = 1 To 96
;~  WinSetTrans("Arvuti_sulgemine","",255 - $i)
;~  Sleep(50)
;~ Next

While 1
Sleep(100)
$R = $R + $step
$G = $G - $step
$time = $time - 1
$text = Int($time / 60)
GUICtrlSetData($Label2,$text&":"&$time - ($text * 60 ))
GUICtrlSetColor($Label2, BitShift($R, -16) + BitShift($G, -8))
WEndoÝ÷ ÙaØwèZ0x,r¸©¶+p¢¹,jëh×6#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 172, 77, 193, 125)
GUISetFont(26, 800, 0, "Palatino Linotype")
$Label1 = GUICtrlCreateLabel("Label1", 24, 8, 110, 51)
GUICtrlSetColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Edited by E1M1

edited

Share this post


Link to post
Share on other sites
Yashied

Ok now I need help with that color step calculator , it gets red when the time is about 1:20 and then ig gets back to green. how to avoid that?

My friend, it was necessary to teach mathematics.

^_^

$step = 255 / $time

Why is "Time to action:" in black color?

$Form1 = GUICreate("Action", 440, 50, 0, 0,0x96000000,0x00000080)

Where are you taking these values to the styles. This is because of them.

WHY in following script it works?

???

http://www.autoitscript.com/autoit3/docs/functions/BitShift.htm

Edited by Yashied

Share this post


Link to post
Share on other sites
E1M1

Great Thanks it works now


edited

Share this post


Link to post
Share on other sites
trancexx

... anyway, it was $WS_CLIPCHILDREN style that caused that.


♡♡♡

.

eMyvnE

Share this post


Link to post
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
Sign in to follow this  

×