mixmax2 Posted January 28, 2006 Share Posted January 28, 2006 can anyone tell me howto do this? im trying to make a color picker in my script and i wanna add 3 sliders, each modify RED, GREEN, or BLUE, and i want an update button that when clicked takes the info from the slider, adds em together like $red+$green+$blue, and then makes em a RGB color code which i can then use to change the color of a label, im extremely new to au3 and the helpfile does not tell me howto add numbers or variables together So someone, please help. Link to comment Share on other sites More sharing options...
greenmachine Posted January 28, 2006 Share Posted January 28, 2006 OK, so RGB colors are set up like this: 0x000000 - 0xFFFFFF (0x just means hex). The red portion is the first two numbers (000000 to FF0000), green is the middle two (000000 to 00FF00), and blue is the last two (000000 to 0000FF). So, all you have to do is modify the respective values and add them together. Example since that was such a crappy explanation: I want something purple. So I slide my red slider to FF and my blue slider to FF as well. Green stays at 00. So now I have red (FF0000) and blue (0000FF). Add them together and you get FF00FF, which is purple. Link to comment Share on other sites More sharing options...
GaryFrost Posted January 28, 2006 Share Posted January 28, 2006 if you have the beta you could just use _ChooseColor UDF in Misc SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
mixmax2 Posted January 28, 2006 Author Share Posted January 28, 2006 OK, so RGB colors are set up like this: 0x000000 - 0xFFFFFF (0x just means hex). The red portion is the first two numbers (000000 to FF0000), green is the middle two (000000 to 00FF00), and blue is the last two (000000 to 0000FF). So, all you have to do is modify the respective values and add them together.Example since that was such a crappy explanation:I want something purple. So I slide my red slider to FF and my blue slider to FF as well. Green stays at 00. So now I have red (FF0000) and blue (0000FF). Add them together and you get FF00FF, which is purple.i still dont know howto add them together, i know all that, i was asking howto add them together to create a color, literally, not how to do it, but HOW to do it. Link to comment Share on other sites More sharing options...
greenmachine Posted January 28, 2006 Share Posted January 28, 2006 It's just normal addition. Just try the color chooser that gafrost suggested. Link to comment Share on other sites More sharing options...
mixmax2 Posted January 28, 2006 Author Share Posted January 28, 2006 (edited) It's just normal addition. Just try the color chooser that gafrost suggested.thats the problem, the helpfile doesnt tell me howto correctly add things.under math, it doesnt have addition or subtraction, just a bunch of advanced stuff. Edited January 28, 2006 by mixmax2 Link to comment Share on other sites More sharing options...
w0uter Posted January 28, 2006 Share Posted January 28, 2006 dont diss the helpfile please. come back once you have read it completely especially "Language Reference" My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
greenmachine Posted January 28, 2006 Share Posted January 28, 2006 The helpfile isn't going to teach you basic addition. That's what school was for. Link to comment Share on other sites More sharing options...
mixmax2 Posted January 28, 2006 Author Share Posted January 28, 2006 The helpfile isn't going to teach you basic addition. That's what school was for.sigh*, no i dont know howto add in the script, omg, i dont know what to type, to make it add anything together, ive tried adding variables like $1+$2+$3, but it doesnt work, arg its getting extremely hard to explain. Link to comment Share on other sites More sharing options...
greenmachine Posted January 28, 2006 Share Posted January 28, 2006 MsgBox (0, "adding", "0x0000ff + 0xff0000 = " & Hex (0x0000ff + 0xff0000)) Link to comment Share on other sites More sharing options...
ChrisL Posted January 28, 2006 Share Posted January 28, 2006 (edited) sigh*, no i dont know howto add in the script, omg, i dont know what to type, to make it add anything together, ive tried adding variables like $1+$2+$3, but it doesnt work, arg its getting extremely hard to explain.You probably need to tell AutoIt that it is a number and not a string, $Result = Number ($1+$2+$3 )Edit.. Looking at the post above this is probably not what you need, but I'll leave it just in case! Edited January 28, 2006 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Developers Jos Posted January 28, 2006 Developers Share Posted January 28, 2006 The color is a 6 character hex code like: 0xAABBCC AA = Red BB = Green CC = Blue If your 3 sliders ($Red,$Green,$Blue) return a decimal value then just do: $Color = "0x" & Hex($Red) & Hex($Green) & Hex($Blue) And update a control by doing: GUICtrlSetColor($YourControl, $Color) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
mixmax2 Posted January 28, 2006 Author Share Posted January 28, 2006 The color is a 6 character hex code like:0xAABBCCAA = RedBB = GreenCC = BlueIf your 3 sliders ($Red,$Green,$Blue) return a decimal value then just do:$Color = "0x" & Hex($Red) & Hex($Green) & Hex($Blue)And update a control by doing:GUICtrlSetColor($YourControl, $Color)ty so much, this one sounds like itll work, im gonna try it out. Link to comment Share on other sites More sharing options...
mixmax2 Posted January 28, 2006 Author Share Posted January 28, 2006 ty so much, this one sounds like itll work, im gonna try it out.k this works great, but now can someone tell me another thing? i have 3 sliders, each one represents R, G, B, next to each slider is a input that represents the number, how can i make the input represent what numberthe slider is on AS the slider is being scrolled? Link to comment Share on other sites More sharing options...
mixmax2 Posted January 28, 2006 Author Share Posted January 28, 2006 $number1 = Number( $1dat + $2dat + $3dat ) is this how you add variables? Link to comment Share on other sites More sharing options...
Developers Jos Posted January 28, 2006 Developers Share Posted January 28, 2006 (edited) $number1 = Number( $1dat + $2dat + $3dat )is this how you add variables?What is this different from what I posted before ?Just update the control with the $color value....EDIT: Or do you want to convert the HEX value back to decimal ? Edited January 28, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Somerset Posted January 28, 2006 Share Posted January 28, 2006 (edited) What is this different from what I posted before ? Just update the control with the $color value.... EDIT: Or do you want to convert the HEX value back to decimal ?nothing wrong with what you said Jdeb i just think they are under the wrong idea of adding the varibles. not just sticking them together to = 1 varible without addition. example as follows it is normally a newbie mistake. $a=10 $b=20 $c=30 now you can go with addition of $z = $a + $b + $c so the result would be $z = 60 the other ways is joing them without addition $z = $a & $b & $c so $z = 102030 big difference. what Jdeb said is the easiest in my opinion. Edited January 28, 2006 by beerman Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 29, 2006 Share Posted January 29, 2006 can anyone tell me howto do this? im trying to make a color picker in my script and i wanna add 3 sliders, each modify RED, GREEN, or BLUE, and i want an update button that when clicked takes the info from the slider, adds em together like $red+$green+$blue, and then makes em a RGB color code which i can then use to change the color of a label, im extremely new to au3 and the helpfile does not tell me howto add numbers or variables together So someone, please help. You seem to be resisting reading the help file for some reason... Anyway, I'm a newbie with AutoIT myself, and it was an interesting project for playing with sliders, so I took the example from the help file for GuiCtrlCreateSlider() and modified it. My version sticks with decimal numbers (0xFF = 255): expandcollapse popup#include <GuiConstants.au3> $SlideGui = GUICreate("Slider Test", 356, 130, 100, 200) GUISetBkColor(0xE0FFFF, $SlideGui) GUICtrlCreateLabel("RED (0-255)", 10, 10, 70, 20) $SliderR = GUICtrlCreateSlider(90, 10, 256, 20) GUICtrlSetLimit($SliderR, 255, 0) GUICtrlSetData($SliderR, 128) GUICtrlCreateLabel("Green (0-255)", 10, 40, 70, 20) $SliderG = GUICtrlCreateSlider(90, 40, 256, 20) GUICtrlSetLimit($SliderG, 255, 0) GUICtrlSetData($SliderG, 128) GUICtrlCreateLabel("Blue (0-255)", 10, 70, 70, 20) $SliderB = GUICtrlCreateSlider(90, 70, 256, 20) GUICtrlSetLimit($SliderB, 255, 0) GUICtrlSetData($SliderB, 128) $Button1 = GUICtrlCreateButton("Value?", 143, 100, 70, 20) GUISetState(@SW_SHOW, $SlideGui) Do $Msg = GUIGetMsg($SlideGui) If $Msg = $Button1 Then $RedVal = GUICtrlRead($SliderR) $GreenVal = GUICtrlRead($SliderG) $BlueVal = GUICtrlRead($SliderB) $Background = ($RedVal * 256 * 256) + ($GreenVal * 256) + ($BlueVal) GUISetBkColor($Background, $SlideGui) MsgBox(0, "Slider Data", "Slider Data = " & @CRLF & _ @TAB & "Red = " & $RedVal & @CRLF & _ @TAB & "Green = " & $GreenVal & @CRLF & _ @TAB & "Blue = " & $BlueVal, 10) EndIf Until $Msg = $Gui_Event_Close Of course, If you WON'T read the help file you may not be able to run it... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
greenmachine Posted January 29, 2006 Share Posted January 29, 2006 Hey, that's actually a really cool program. You think you could get it to change the slider background color at the same time as the rest of the GUI? Or, leave the sliders white so you can actually see them? If either of those, that'd be really cool. 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