November Posted February 28, 2009 Posted February 28, 2009 Hi there guys!!! This is a new version of one of my posts This was a request from a person from my job. This is a little program tha captures the color from your desktop and convert it to RGB and YMCK format (and YMC too...). There are a lot of free software for this, and this one is another free version I hope you like it and be usefull. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <Constants.au3> 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() ;Tray GUI Creation $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() ;Hex color to RGB $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) ;Convert RGB to CMY $cyanr = 1-($r/255) $magentar = 1-($g/255) $yellowr= 1-($b/255) ;Convert CMY to CMYK $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 ;Let's get only the three decimal numbert to match YMCK requirements $cyan = StringFormat("%.3f", $cyanr) $magenta = StringFormat("%.3f", $magentar) $yellow = StringFormat("%.3f", $yellowr) $k = StringFormat("%.3f", $kr) ;Output results in a a ballon or to the clipboard $output = "Hexadecimal : " & $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 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]
Yashied Posted March 1, 2009 Posted March 1, 2009 Good idea, but less than the CMYK color space than RGB. Here it is necessary to use a profile for the printing device and the parameters of color separation. For this purpose, better to use Photoshop. But the learning good example. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
redraven Posted March 2, 2009 Posted March 2, 2009 thank you for sharing this one bro!! i know u did a hardwork... u get ten thumbs from me:D
jvanegmond Posted March 4, 2009 Posted March 4, 2009 (edited) Simpler method to get RGB. $Hex = 0xAABBCC $R = BitShift(BitAND($Hex,0xFF0000),16) $G = BitShift(BitAND($Hex, 0xFF00),8) $B = BitAND($Hex, 0xFF) MsgBox(0,"","Hex: " & $Hex & @CRLF & _ "R: " & $R & @CRLF & _ "G: " & $G & @CRLF & _ "B: " & $B) also defined in Color.au3 under functions _ColorGetX. X can be Red, Green or Blue. Very fast. Edited March 4, 2009 by Manadar github.com/jvanegmond
November Posted March 5, 2009 Author Posted March 5, 2009 Simpler method to get RGB. $Hex = 0xAABBCC $R = BitShift(BitAND($Hex,0xFF0000),16) $G = BitShift(BitAND($Hex, 0xFF00),8) $B = BitAND($Hex, 0xFF) MsgBox(0,"","Hex: " & $Hex & @CRLF & _ "R: " & $R & @CRLF & _ "G: " & $G & @CRLF & _ "B: " & $B) also defined in Color.au3 under functions _ColorGetX. X can be Red, Green or Blue. Very fast. Ok Manadar... thanks for the useful tips. I'll get it a try and see if the script performance get better. 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