Jump to content

Recommended Posts

Posted

i am writing a little script for fun at work. i am trying to make a slider that changes the color of a label. basically

i want the label to display all the possible colors. as i move the slider, the color of the label would change. the problem i have is i cant get all the color. wut i have so far

$slider = GUICtrlCreateSlider (10,75,150,20)
GUICtrlSetLimit(-1,255,0)
GUICtrlSetData($slider,0)
;color display
$label = GUICtrlCreateLabel("",10,10,50,50)
GUICtrlSetBkColor($label,guictrlread($slider))

while 1
$meter = guictrlread($slider)
    GUICtrlSetBkColor($label,$meter)
    GUICtrlSetData($reading,Hex($meter,8) )
wend

once it reaches the upper limit of 255 the color repeats itself. i tried to put 0x00ffffff as the upper limit

but the slider wont move.

appreciate any help.

  • Moderators
Posted

If your using Beta, might give you a hint to look at _ColorGet...(), you'll see that the colors are returned 0 to 255, I'm sure this has some relevance.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted (edited)

#include <GUIConstants.au3>
$GUI = GUICreate("Colors", 561, 257, 192, 125)
$color = GUICtrlCreateLabel("", 36, 40, 492, 76)
$hex = GUICtrlCreateLabel("",250,150,150)
$r = GUICtrlCreateSlider(104, 176, 369, 17)
GUICtrlSetLimit(-1,255,0)
GUICtrlCreateLabel("Red",80,176)
$g = GUICtrlCreateSlider(104, 200, 369, 17)
GUICtrlSetLimit(-1,255,0)
GUICtrlCreateLabel("Green",70,200)
$b = GUICtrlCreateSlider(104, 224, 369, 17)
GUICtrlSetLimit(-1,255,0)
GUICtrlCreateLabel("Blue",80,224)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
            GUICtrlSetBkColor($color,"0x" & Hex(GUICtrlRead($r),2) & Hex(GUICtrlRead($g),2) & Hex(GUICtrlRead($b),2))
            GUICtrlSetData($hex,"0x" & Hex(GUICtrlRead($r),2) & Hex(GUICtrlRead($g),2) & Hex(GUICtrlRead($b),2))
        If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

not really tested just quickness i think it works

WTF highlighting syntax isnt working

SHHH DONT TELL ANYONE I DID RBG INSTEAD OF RGB lol fixed :)

Edited by thatsgreat2345
Posted

i am writing a little script for fun at work. i am trying to make a slider that changes the color of a label.

Try this:

#include <string.au3>
#include <GUIConstants.au3>

HotKeySet("{ESC}","_terminate")
Dim $reading, $msg
Opt ("TrayIconDebug",1)
GUICreate("My gui",400,400,200,200)
$sliderR = GUICtrlCreateSlider (10,75,150,20)
GUICtrlSetLimit(-1,255,0)
$sliderG = GUICtrlCreateSlider (10,105,150,20)
GUICtrlSetLimit(-1,255,0)
$sliderB = GUICtrlCreateSlider (10,135,150,20)
GUICtrlSetLimit(-1,255,0)
GUICtrlSetData($sliderR,0)
GUICtrlSetData($sliderG,0)
GUICtrlSetData($sliderB,0)
;color display
$label = GUICtrlCreateLabel("",10,10,50,50)
GUICtrlSetBkColor($label,guictrlread($sliderR))
GUISetState(@SW_SHOW)

while 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    
    $meter = guictrlread($sliderR)
    GUICtrlSetBkColor($label,"0x" & Hex(guictrlread($sliderR),2) & Hex(guictrlread($sliderG),2) & Hex(guictrlread($sliderB),2))
    ToolTip(Hex(guictrlread($sliderR),2) & @CRLF & Hex(guictrlread($sliderG),2) & @CRLF & Hex(guictrlread($sliderB),2))
;ToolTip(_StringToHex(GUICtrlRead($sliderR)) & @CRLF & _StringToHex(GUICtrlRead($sliderG)) & @CRLF & _StringToHex(GUICtrlRead($sliderB)))
    GUICtrlSetData($reading,Hex($meter,8) )
wend
Func _terminate()
    exit 0
EndFunc
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Posted (edited)

not really tested just quickness i think it works

WTF highlighting syntax isnt working

thatsgreat2345-

That's why you beat me by 60 seconds!!! :) You qwazy wabbit! Mine is actually tested (sort of)... :(

jefhal

Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Posted

thatsgreat2345-

That's why you beat me by 60 seconds!!! :( You qwazy wabbit! Mine is actually tested (sort of)... :D

jefhal

lol ill give it to you i beat you but mine didnt auto update so i made it but my post is still first :)

Posted

lol ill give it to you i beat you but mine didnt auto update so i made it but my post is still first :)

Either way, "THAT'S what I call great customer service!"
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Posted

since the gay arrays werent working ( stupid arrays) i did it the hard way , good thing for copy and paste :)

#include <GUIConstants.au3>
$GUI = GUICreate("Color Chooser", 579, 289, 192, 125)
GUISetBkColor(0xF1EFE2)
$color1 = GUICtrlCreateLabel("", 24, 16, 84, 84)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$color2 = GUICtrlCreateLabel("", 136, 16, 84, 84)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$color3 = GUICtrlCreateLabel("", 248, 16, 84, 84)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$color4 = GUICtrlCreateLabel("", 360, 16, 84, 84)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$color5 = GUICtrlCreateLabel("", 472, 16, 84, 84)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$choose1 = GUICtrlCreateRadio("Color 1", 24, 112, 65, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$choose2 = GUICtrlCreateRadio("Color 2", 136, 112, 65, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$choose3 = GUICtrlCreateRadio("Color 3", 248, 112, 65, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$choose4 = GUICtrlCreateRadio("Color 4", 360, 112, 65, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$choose5 = GUICtrlCreateRadio("Color 5", 472, 112, 65, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$input1 = GUICtrlCreateInput("", 16, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
$input2 = GUICtrlCreateInput("", 128, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
$input3 = GUICtrlCreateInput("", 248, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
$input4 = GUICtrlCreateInput("", 352, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
$input5 = GUICtrlCreateInput("", 464, 136, 81, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlCreateLabel("Red", 16, 192, 24, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
GUICtrlCreateLabel("Green", 16, 216, 33, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
GUICtrlCreateLabel("Blue", 16, 240, 25, 17)
GUICtrlSetBkColor(-1, 0xF1EFE2)
$Red = GUICtrlCreateSlider(56, 192, 462, 21)
GUICtrlSetLimit(-1,255,0)
$Green = GUICtrlCreateSlider(56, 216, 462, 21)
GUICtrlSetLimit(-1,255,0)
$Blue = GUICtrlCreateSlider(56, 240, 462, 21)
GUICtrlSetLimit(-1,255,0)
GUISetState(@SW_SHOW)
WHile 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
If GUICtrlRead($choose1) = $GUI_CHECKED Then
    GUICtrlSetBkColor($color1,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
    GUICtrlSetData($input1,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
ElseIf GUICtrlRead($choose2) = $GUI_CHECKED Then
    GUICtrlSetBkColor($color2,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
    GUICtrlSetData($input2,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
ElseIf GUICtrlRead($choose3) = $GUI_CHECKED Then
    GUICtrlSetBkColor($color3,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
    GUICtrlSetData($input3,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
ElseIf GUICtrlRead($choose4) = $GUI_CHECKED Then
    GUICtrlSetBkColor($color4,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
    GUICtrlSetData($input4,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
ElseIf GUICtrlRead($choose5) = $GUI_CHECKED Then
    GUICtrlSetBkColor($color5,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
    GUICtrlSetData($input5,"0x" & Hex(GUICtrlRead($Red),2) & Hex(GUICtrlRead($Green),2) & Hex(GUICtrlRead($Blue),2))
EndIf
WEnd
Posted

YahYah! I likee. By the way, I know you can taste the difference, but which one do you like better?: The regular or the lo-fat Harvest product?

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Posted

Surprisingly i like the low fat better :) i was like hmmmm did they magically get better and then i went home and checked out the bag and i was like WOW they are 30% less fat its amazing dont panic now

  • Moderators
Posted

Surprisingly i like the low fat better :( i was like hmmmm did they magically get better and then i went home and checked out the bag and i was like WOW they are 30% less fat its amazing dont panic now

If you have to worry how much fat is in something at 13, you need to step away from the computer and go join a sports program at school! :)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

If you have to worry how much fat is in something at 13, you need to step away from the computer and go join a sports program at school! :)

HAHAHHH i never said i was worrying im just saying i like them better, and im 16 and i play soccer

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
×
×
  • Create New...