buzz44 1 Posted February 22, 2005 (edited) im making a simple script that will convert the RGB to Hex and visversa in a GUI format ... and a little coloured label will chnage so that u know wat colour it is .. because RGB is a value 1-255 i dont want the values to be less than "0" or greater than "255" which i have done... the problem is the blue code below ... it recognises not the whole string . but the first 2 digits or sumthing .. eg... if i type the number 174 in it works fine ... but say if i type the number in 26 it immediatly jumps the number to 255 .. alos if i put "026" instead of "26" it works .. but as soon as i click the "updown" thing is jumps to 255 again .. is there andway i can correct this so that is reads 255 as a whole not as 25.. thx expandcollapse popup; Script generated by AutoBuilder 0.5 Prototype #include <GuiConstants.au3> If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GuiCreate("MyGUI", 162, 81,(@DesktopWidth-162)/2, (@DesktopHeight-81)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Input_Red = GuiCtrlCreateInput("255", 10, 24, 40, 20, $ES_NUMBER) $Input_Green = GuiCtrlCreateInput("255", 60, 24, 40, 20, $ES_NUMBER) $Input_Blue = GuiCtrlCreateInput("255", 110, 24, 40, 20, $ES_NUMBER) $Input_Hex = GuiCtrlCreateInput("Input4", 10, 50, 80, 20) $Label_Blue = GuiCtrlCreateLabel("Blue", 110, 10, 30, 13) $Label_Red = GuiCtrlCreateLabel("Red", 10, 10, 40, 11) $Label_Green = GuiCtrlCreateLabel("Green", 60, 10, 40, 14) $Label_Colour = GuiCtrlCreateLabel("", 100, 50, 50, 20) $updown_Red = GUICtrlCreateUpdown($Input_Red) $updown_Blue = GUICtrlCreateUpdown($Input_Blue) $updown_Green = GUICtrlCreateUpdown($Input_Green) GUICtrlSetPos($Input_Red, 10,20, 50, 20 ) GUICtrlSetPos($Input_Blue, 60,20, 50, 20 ) GUICtrlSetPos($Input_Green, 120,20, 50, 20 ) GuiSetState() While 1 _GetHex() ;;;;;HERE IS MY PROBLEM___________________________ If GUICtrlRead ($Input_Red) > "255" Then GUICtrlSetData ($Input_Red, "255") ElseIf GUICtrlRead ($Input_Green) > "255" Then GUICtrlSetData ($Input_Green, "255") ElseIf GUICtrlRead ($Input_Blue) > "255" Then GUICtrlSetData ($Input_Blue, "255") ElseIf GUICtrlRead ($Input_Red) < "0" Then GUICtrlSetData ($Input_Red, "0") ElseIf GUICtrlRead ($Input_Green) < "0" Then GUICtrlSetData ($Input_Green, "0") ElseIf GUICtrlRead ($Input_Blue) < "0" Then GUICtrlSetData ($Input_Blue, "0") ;;;;;HERE IS MY PROBLEM___________________________ EndIf $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit Func _GetHex() $Hex_Red = Hex(GUICtrlRead ($Input_Red), 2) $Hex_Green = Hex(GUICtrlRead ($Input_Green), 2) $Hex_Blue = Hex(GUICtrlRead ($Input_Blue), 2) GUICtrlSetData ($Input_Hex, "0x" & $Hex_Red & $Hex_Green & $Hex_Blue) GUICtrlSetBkColor($Label_Colour, GUICtrlRead ($Input_Hex)) EndFunc edit: didnt realise i could have colour inside code tags =( Edited February 22, 2005 by burrup qq Share this post Link to post Share on other sites
Lazycat 13 Posted February 22, 2005 (edited) You should compare numerical values, not strings. If Number(GUICtrlRead ($Input_Red)) > 255 Then GUICtrlSetData ($Input_Red, "255") e.t.c. But even better to get rid all code between ";;;;;HERE IS MY PROBLEM___________________________ " and just use limits for Updown control: $updown_Red = GUICtrlCreateUpdown($Input_Red) GUICtrlSetLimit(-1, 255, 0) $updown_Blue = GUICtrlCreateUpdown($Input_Blue) GUICtrlSetLimit(-1, 255, 0) $updown_Green = GUICtrlCreateUpdown($Input_Green) GUICtrlSetLimit(-1, 255, 0) Edit: second example valid, but you still can enter any value by hand... so this not for your case. Edited February 22, 2005 by Lazycat Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Share this post Link to post Share on other sites
buzz44 1 Posted February 22, 2005 (edited) cool Thx ... you 2nd eg ... thats why i didnt use that method lol .. but i still could and use GUICtrlRead($Input_red) to check if it is over 255 .. thx edit: u can type in a number over 255 but asoon as u click up or down it sets it back to 255 so its ok. Edited February 22, 2005 by burrup qq Share this post Link to post Share on other sites
Blue_Drache 260 Posted February 22, 2005 cool Thx ... you 2nd eg ... thats why i didnt use that method lol .. but i still could and use GUICtrlRead($Input_red) to check if it is over 255 .. thxedit: u can type in a number over 255 but asoon as u click up or down it sets it back to 255 so its ok.<{POST_SNAPBACK}>You could also stringformat(var1=%3d,$input_red) to force everything into a 3 digit number that is zero padded. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Share this post Link to post Share on other sites