Jump to content

AutoColour


spyrorocks
 Share

Recommended Posts

OK, i made this utillity a few weeks ago and i use it a lot. Since i use it quite a bit, im gonna post it here for you guys to enjoy. What it does is allows you to grab the HTML colour code for any colour on your screen by dragging your mouse over the colour you want then freezing the display and copying it to your clipboard with a simple button.

Commands:

Push CTRL+F to freeze/Un-Freeze the colour display.

Push "Copy Colour Code To Clipboard" to copy the selected colour code to your clipboard (Example: #00FF00)

and thats pretty much it.

Here is the code:

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

hotkeyset("^f", "freeze")

$parent = GUICreate("Parent")
$colour_pick = GUICreate("AutoColor", 305, 96, @desktopwidth - 307, @desktopheight - 20 - 130, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE), $parent)
$current_colour = GUICtrlCreateLabel("", 6, 10, 87, 79)
GUICtrlSetBkcolor(-1, 0xFFFFFF)
GUICtrlCreateLabel("HTML Colour Code:", 106, 12, 102, 17)
$text_colourcode = GUICtrlCreateInput("#FF00FF", 200, 10, 55, 21)
$copy_toclip = GUICtrlCreateButton("Copy Colour Code To Clipboard", 96, 32, 175, 17, 0)
GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif")
$status = GUICtrlCreateLabel("", 96, 62, 175, 17, $SS_CENTER)
GUISetState(@SW_SHOW)

global $freezing = 0
$colour = ""

While 1
    $nMsg = GUIGetMsg()
    if $nmsg = $GUI_EVENT_CLOSE then Exit
    if $nmsg = $copy_toclip then copyit()

$mouse = MouseGetPos ()
    if PixelGetcolor( $mouse[0] , $mouse[1] ) <> $colour and not $freezing then
    $mouse = MouseGetPos ()
    $colour = PixelGetcolor( $mouse[0] , $mouse[1] )
    GUICtrlSetBkcolor($current_colour, $colour)
    guictrlsetdata($text_colourcode, "#" & Hex($colour, 6))
    endif
WEnd

func copyit()
$colour = guictrlread($text_colourcode)

    if ClipPut ($colour) then
    guictrlsetdata($status, "Copyed "&$colour&" To ClipBoard")
    else
    guictrlsetdata($status, "Error Coping colourcode to clipboard.")
    endif
endfunc


func freeze()
    if $freezing then
    global $freezing = 0
    guictrlsetdata($status, "Freeze Off")
    else
    global $freezing = 1
    guictrlsetdata($status, "Freeze On")
    endif
endfunc
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...