FireFox Posted March 15, 2009 Posted March 15, 2009 Hi, I need color conversion from hexadecimal to a color string like 0xFF000000 Because when I enter red color in hexadecimal, I get blue color... The output color is for draw pixel : HotKeySet("{ESC}","Quit"); Press ESC to quit Global $CENTER_X = Int(@DesktopWidth/2) Global $CENTER_Y = Int(@DesktopHeight/2) $REFRESH = InputBox("DrawLines","Refresh time","5") While 1 DrawLines() Sleep(GUICtrlRead($REFRESH*1000)) WEnd Func DrawLines() $DC = DllCall ("user32.dll", "int", "GetDC", "hwnd", "") For $INDEX = $CENTER_X - 25 To $CENTER_X + 25 DrawPixel($DC,$INDEX,$CENTER_Y,0x00FF00) Next For $INDEX = $CENTER_Y - 25 To $CENTER_Y + 25 DrawPixel($DC,$CENTER_X,$INDEX,0x00FF00) Next EndFunc Func DrawPixel($hDC,$X,$Y,$COLOR) DllCall ("gdi32.dll", "long", "SetPixel", "long", $hDC[0], "long", $X, "long", $Y, "long", $COLOR) EndFunc Func Quit() Exit EndFunc Thanks for anyhelp Cheers, FireFox.
ProgAndy Posted March 15, 2009 Posted March 15, 2009 Well, SetPixel wants the color in BGR-Format, not RGB. You can change this in your code or use a color-convert function. Just search in the forum for it. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
November Posted March 16, 2009 Posted March 16, 2009 Hi there, Can you take any juice from this? expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.13.8 (beta) Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <Constants.au3> #NoTrayIcon Opt("TrayAutoPause",1) Opt("TrayMenuMode",1) HotKeySet("^!x" , "getcolor") HotKeySet("{ESC}" , "fexit") $setclip = 1 dim $vdif, $wdif, $output, $black, $cyanng, $magentang, $yellowng $main = GUICreate("Get cursor Color", 75, 45, @DesktopWidth - 140, @DesktopHeight - 120, $WS_BORDER, $WS_EX_CLIENTEDGE + $WS_EX_TOPMOST ) GUISetState() $Clip = TrayCreateItem("To Clipboard ") TrayItemSetState($clip, $TRAY_CHECKED) $setclip = 1 TrayCreateItem("") $valitem = TrayCreateItem("Instructions") TrayCreateItem("") $aboutitem = TrayCreateItem("About") TrayCreateItem("") $exit = TrayCreateItem("Exit") TraySetState() While 1 $mouse = MouseGetPos() $msg = TrayGetMsg() Select Case $msg = 0 $var = PixelGetColor( $mouse[0] , $mouse[1]) $background = GUICtrlSetBkColor($main, $var) GUISetBkColor($var, $main) ContinueLoop Case $msg = $Clip $decide = TrayItemGetState($clip) If $decide = 1 then $setclip = 1 Else $setclip = 0 endif Case $msg = $valitem Msgbox(64,"Instructions:","ALT+CTRL+X - Get Color" & @CRLF & "ESC - Exit Program") Case $msg = $aboutitem Msgbox(64,"About:","November 2009" & @CRLF & "Free usage") Case $msg = $exit exit EndSelect WEnd Func getcolor() $output = "" $hex = Hex ( $var , 6) $HR = StringMid($hex, 1, 2) $HG = StringMid($hex, 3, 2) $HB = StringMid($hex, 5, 2) $R = Dec($HR) $G = Dec($HG) $B = Dec($HB) $cyanr = 1-($r/255) $magentar = 1-($g/255) $yellowr= 1-($b/255) $blackr=1 If $blackr > $cyanr Then $blackr = $cyanr if $blackr > $magentar Then $blackr= $magentar if $blackr > $yellowr Then $blackr = $yellowr if $blackr = 1 Then $cyanr = 0 $magentar = 0 $yellowr = 0 Else $cyanr = ($cyanr-$blackr)/(1-$blackr) $magentar = ($magentar-$blackr)/(1-$blackr) $yellowr = ($yellowr-$blackr)/(1-$blackr) EndIf $kr = $blackr $cyan = StringFormat("%.3f", $cyanr) $magenta = StringFormat("%.3f", $magentar) $yellow = StringFormat("%.3f", $yellowr) $k = StringFormat("%.3f", $kr) $output = "Hexadecimal : " & "0x" & $hex & @CRLF $output = $output & "RGB : " & $R & ", " & $G & ", " & $B & @CRLF $output = $output & "CYMK : C-" & $cyan & ", M-" & $magenta & ", Y-" & $yellow & ", K-" & $k TrayTip("RGB / CYMK Color", $output, 1) $backup = ClipGet() If $setclip = 1 then ClipPut($output) Else ClipPut($backup) EndIf EndFunc func fexit() Exit EndFunc Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font]
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