Jump to content

AutoIT coding questions


Recommended Posts

Hey guys, was wondering if it was possible to impliment a Color picker into an autoit program. Something like a color dropper u can drag onto the screen, and it will pick the certain color, and then do actions with clicking based on that selected color.

Thanks in advance for any help xD

Link to comment
Share on other sites

You can choose a color with _ChooseColor.

I use this to get the hex value of a color on the screen (Whipped up in like 10 minutes last month)

#include <GUIConstantsEx.au3>
#Include <Misc.au3>
#include <EditConstants.au3>
Global $nCont = 0, $xColor = 0x000000, $iRunning = False
$hGUI = GUICreate("ColorSelect_Tool", 220, 110, -1, -1)
WinSetOnTop($hGUI, "", 1)
$hColor = GUICtrlCreateLabel("", 0, 0, 50, 50)
$hSelectColorFromScreen = GUICtrlCreateButton("Select Color from Screen", 70, 0)
$hHex = GUICtrlCreateInput("", 1, 70, 100, -1, $ES_READONLY)
GUICtrlSetBkColor($hHex, 0xFFFFFF)
GUISetState()
While 1
    If GUIGetMsg() = $hSelectColorFromScreen Then
        Do
            If PixelGetColor(MouseGetPos(0), MouseGetPos(1)) <> $xColor Then
                $xColor = PixelGetColor(MouseGetPos(0), MouseGetPos(1))
                GUICtrlSetBkColor($hColor, $xColor)
                GUICtrlSetData($hHex, "0x" & StringRight(Hex($xColor), 6))
            EndIf
        Until _IsPressed(01)
    EndIf
    If GUIGetMsg() = -3 Then
        Exit
    EndIf
WEnd

Click Choose Color, and then click in any spot to "Freeze" it.

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...