Jump to content

Pixel Color V2.


Nahuel
 Share

Recommended Posts

Ok, so I grabbed a couple of other users' scripts and updated my Screen Color Picker tool.

Functions I added:

*Magnify Under Mouse (by Larry) for more precision.

*Move cursor with keyboard (By Monamor) for more precision.

*Use for Active window only or full screen (By xwinterx)

Screenshot:

Posted Image

Compiled .exe

Pixel_Color_V2.ENG.exe

Source:

#include <GUIconstants.au3>
#include<Misc.au3>
#NoTrayIcon

Opt("WinTitleMatchMode", 4)
Opt("WinWaitDelay", 0)
Opt("GUIonEventMode",1)

;~ Global $SRCCOPY = 0x00CC0020
Global $leave = 0
Global $Paused=0
$MouseModifier = 1
$PressedTime = 1

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{INS}", "_copyHEX")

Tooltip("AU3MAG", 0, 0,"","",4)
$MyhWnd = WinGetHandle("classname=tooltips_class32")

GUICreate("Pixel Color", 180, 410,0, 0, -1, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")

GUICtrlCreateGroup(" Mouse coords ", 10, 10, 160, 50)
GUICtrlCreateLabel("X:", 25, 33, 15, 15)
$MousePosX=GUICtrlCreateInput("", 40, 30, 40, 20, $ES_READONLY)
GUICtrlCreateLabel("Y:", 90, 33, 15, 15)
$MousePosY=GUICtrlCreateInput("", 105, 30, 40, 20, $ES_READONLY)

GUICtrlCreateGroup(" Color codes ", 10, 70, 160, 110)
GUICtrlCreateLabel("Decimal:", 25, 93, 50, 15)
$PixelColor=GUICtrlCreateInput("", 80, 90, 70, 20, $ES_READONLY)
GUICtrlCreateLabel("Hex:", 25, 123, 50, 15)
$hexColor=GUICtrlCreateInput("", 80, 120, 70, 20,$ES_READONLY)
GUICtrlCreateLabel("Color:", 25, 153, 50, 15)
$MostrarColor=GUICtrlCreateLabel("", 80, 150, 70, 20,$ES_READONLY)

GUICtrlCreateGroup(" Special options ", 10, 190, 160, 145)
$RB_Full = GUICtrlCreateRadio("Full Screen", 25, 210, 100, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$RB_Window = GUICtrlCreateRadio("Active Window", 25, 230, 100, 20)
$Mag= GUICtrlCreateCheckbox("Magnify", 25, 250, 100, 20)
$Solid= GUICtrlCreateRadio("Solid crosshair", 35, 270, 100, 20)
$Inver= GUICtrlCreateRadio("Inverted crosshair", 35, 290, 120, 20)
$KeyBMouse= GUICtrlCreateCheckbox("Move cursor with keyb.", 25, 310, 140, 20)

$Ayuda=GUICtrlCreateButton("Help",10,345,77)
GUICtrlSetOnEvent(-1,"Ayuda")
$Saltar=GUICtrlCreateButton("Jump to",92,345,77)
GUICtrlSetOnEvent(-1,"Saltar")

GUICtrlCreateLabel("PAUSE: Freeze/Unfreeze", 0, 380 ,180,15,$SS_CENTER)
GUICtrlSetColor(-1,0x00808080)
GUICtrlCreateLabel("INS: Copy hex code to clipboard", 0, 395 ,180,15,$SS_CENTER)
GUICtrlSetColor(-1,0x00808080)


GUISetState()
data()

Func data()

    While 1
        Sleep(50)
        Opt("WinTitleMatchMode",4)
        If (_IsPressed(25) + _IsPressed(26) + _IsPressed(27) + _IsPressed(28)) = 0 Then
        _ResetSpeed()
        EndIf
        $msg=GUIGetMsg()
        Select
            Case $msg=$GUI_EVENT_CLOSE
                Exit
        EndSelect
        
        If GUICtrlRead($KeyBMouse)=$GUI_CHECKED Then
            MouseKeyb()
        Else
            MouseKeybNO()
        EndIf
        
        If GUICtrlRead($Mag)=$GUI_CHECKED Then
            GUICtrlSetState($RB_Window,$GUI_DISABLE)
            GUICtrlSetState($Solid,$GUI_ENABLE)
            GUICtrlSetState($Inver,$GUI_ENABLE)
            GUICtrlSetState($RB_Full,$GUI_CHECKED)
            WinSetState($MyhWnd,"",@SW_SHOW)
            MAG()
            
        Else
            GUICtrlSetState($Solid,$GUI_DISABLE+$GUI_UNCHECKED)
            GUICtrlSetState($Inver,$GUI_DISABLE+$GUI_UNCHECKED)
            GUICtrlSetState($RB_Window,$GUI_ENABLE)
            WinSetState($MyhWnd,"",@SW_HIDE)
        EndIf
        If GUICtrlRead($RB_Full) = $GUI_CHECKED Then
            Opt("MouseCoordMode", 1)
            Opt("PixelCoordMode", 1)
            $pos=MouseGetPos()
            $color=PixelGetColor($pos[0],$pos[1])
            GUICtrlSetData($MousePosX, $pos[0])
            GUICtrlSetData($MousePosY, $pos[1])
            GUICtrlSetData($PixelColor,$color)
            $HEX6=StringRight(Hex($color),6)
            GUICtrlSetData($hexColor,"0x"&$HEX6)
            GUICtrlSetBkColor($MostrarColor,"0x"&Hex($color))
        Else
            Opt("MouseCoordMode", 0)
            Opt("PixelCoordMode", 0)
            Opt("WinTitleMatchMode",1)
            $win = WinGetPos("")
            $pos=MouseGetPos()
            If $pos[0] >= 0 And $pos[0] <= $win[2] and $pos[1] >= 0 And $pos[1] <= $win[3] Then
                $color=PixelGetColor($pos[0],$pos[1])
                GUICtrlSetData($MousePosX, $pos[0])
                GUICtrlSetData($MousePosY, $pos[1])
                GUICtrlSetData($PixelColor,$color)
                $HEX6=StringRight(Hex($color),6)
                GUICtrlSetData($hexColor,"0x"&$HEX6)
                GUICtrlSetBkColor($MostrarColor,"0x"&Hex($color))
            Else
                GUICtrlSetData($MousePosX, "----")
                GUICtrlSetData($MousePosY, "----")
                GUICtrlSetData($PixelColor,"")
                GUICtrlSetData($hexColor,"")
            EndIf
        EndIf
    WEnd
EndFunc

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(10)
        $msg=GUIGetMsg()
        Select
            Case $msg=$GUI_EVENT_CLOSE
                Exit
        EndSelect
    WEnd
EndFunc

Func MAG()
  $MyHDC = DLLCall("user32.dll","int","GetDC","hwnd",$MyhWnd)
  If @error Then Return
  $DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0)
  If Not @error Then
     $xy = MouseGetPos()
     If Not @error Then
        $l = $xy[0]-10
        $t = $xy[1]-10
        DLLCall("gdi32.dll","int","StretchBlt","int",$MyHDC[0],"int",0,"int",0,"int",100,"int",100,"int",$DeskHDC[0],"int",$l,"int",$t,"int",20,"int",20,"long",$SRCCOPY)
        If $xy[0]<(@DesktopWidth-120) then
            $XArea= $xy[0] + 20
        Else
            $XArea= $xy[0] - 120
        EndIf
        If $xy[1]<(@DesktopHeight-120) then
            $YArea= $xy[1] + 20
        Else
            $YArea= $xy[1] - 120    
        EndIf
        WinMove($myhwnd, "",$XArea,$YArea , 100, 100)
        If GUICtrlRead($Solid)=$GUI_CHECKED Then
            CrossHairsSOLID($MyHDC[0])
        EndIf
        If  GUICtrlRead($Inver)=$GUI_CHECKED Then
            CrossHairsINV($MyHDC[0])
        EndIf
     EndIf
     DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0)
  EndIf
  DLLCall("user32.dll","int","ReleaseDC","int",$MyHDC[0],"hwnd",$MyhWnd)
EndFunc

Func Ayuda()
    MsgBox(0,"Help","*Use magnifier for more presicion." & @CRLF & "" & @CRLF & "*Use 'move cursor with keyboard' option for more presicion." & @CRLF & "   -Keeping arrow key pressed increases speed." & @CRLF & "   -Shift+'arrow' moves mouse cursor faster." & @CRLF & "" & @CRLF & "*Use 'Jump to' to move mouse cursor to a specified pixel" & @CRLF & @CR&"*Press PAUSE to freeze and unfreeze." & @CRLF & "" & @CRLF &"*Press INS to copy HEX code to clipboard.")
EndFunc

Func Saltar()
    Do
    $SaltarCord=InputBox("Jump to","Enter pixel coordinates you want to jump to."&@CRLF&"Example: 123,420",MouseGetPos(0)&","&MouseGetPos(1),"",150,150)
    $CoordsM=StringSplit($SaltarCord,",")
    Until @error OR ($CoordsM[1]<=@DesktopWidth AND $CoordsM[2]<=@DesktopHeight)
    if not @error Then
        BlockInput(1)
        MouseMove($CoordsM[1],$CoordsM[2])
        BlockInput(0)
    EndIf   
EndFunc

Func MouseKeyb()

HotKeySet("+{UP}", "_UpArrow")
HotKeySet("{UP}", "_UpArrow")
HotKeySet("+{DOWN}", "_DownArrow")
HotKeySet("{DOWN}", "_DownArrow")
HotKeySet("+{LEFT}", "_LeftArrow")
HotKeySet("{LEFT}", "_LeftArrow")
HotKeySet("+{RIGHT}", "_RightArrow")
HotKeySet("{RIGHT}", "_RightArrow")
EndFunc

Func MouseKeybNO()
HotKeySet("+{UP}")
HotKeySet("{UP}")
HotKeySet("+{DOWN}")
HotKeySet("{DOWN}")
HotKeySet("+{LEFT}")
HotKeySet("+{LEFT}")
HotKeySet("{LEFT}")
HotKeySet("+{RIGHT}")
HotKeySet("{RIGHT}")
EndFunc

Func nada()
EndFunc

Func _copyHEX()
    ClipPut(Guictrlread($hexColor))
EndFunc;==>_ShowInfo

Func _UpArrow()
    Local $MousePos = MouseGetPos()
    If _IsPressed(10) Then
        $i = 10
    Else
        $i = 1
    EndIf
    
    If $MousePos[1] > 0 Then
        _BoostMouseSpeed()
        MouseMove($MousePos[0], $MousePos[1] - ($MouseModifier * $i), 1)
    EndIf
EndFunc;==>_UpArrow

Func _DownArrow()
    If _IsPressed(10) Then
        $i = 10
    Else
        $i = 1
    EndIf

    Local $MousePos = MouseGetPos()
    If $MousePos[1] < @DesktopHeight Then
        _BoostMouseSpeed()
        MouseMove($MousePos[0], $MousePos[1] + ($MouseModifier * $i),1)
    EndIf
EndFunc;==>_DownArrow

Func _LeftArrow()
    If _IsPressed(10) Then
        $i = 10
    Else
        $i = 1
    EndIf

    Local $MousePos = MouseGetPos()
    If $MousePos[0] > 0 Then
        _BoostMouseSpeed()
        MouseMove($MousePos[0] - ($MouseModifier * $i), $MousePos[1],1)
    EndIf
EndFunc;==>_LeftArrow

Func _RightArrow()
    If _IsPressed(10) Then
        $i = 10
    Else
        $i = 1
    EndIf

    Local $MousePos = MouseGetPos()
    If $MousePos[0] < @DesktopWidth Then
        _BoostMouseSpeed()
        MouseMove($MousePos[0] + ($MouseModifier * $i), $MousePos[1],1)
    EndIf
EndFunc;==>_RightArrow

Func _BoostMouseSpeed()
        If IsInt($PressedTime / 10) Then
            $MouseModifier = $MouseModifier + 1
            $PressedTime = $PressedTime + 1
        Else
            $PressedTime = $PressedTime + 1
        EndIf
EndFunc

Func _ResetSpeed()
    $MouseModifier = 1
    $PressedTime = 1
EndFunc;==>_ResetSpeed

Func CrossHairsSOLID(ByRef $hdc)
    Local $hPen, $hPenOld
    $hPen = DllCall("gdi32.dll","hwnd","CreatePen","int",0,"int",5,"int",0x555555)
    $hPenOld = DllCall("gdi32.dll","hwnd","SelectObject","int",$hdc,"hwnd",$hPen[0])
    DLLCall("gdi32.dll","int","MoveToEx","int",$hdc,"int",52,"int",0,"ptr",0)
    DLLCall("gdi32.dll","int","LineTo","int",$hdc,"int",52,"int",46)
    DLLCall("gdi32.dll","int","MoveToEx","int",$hdc,"int",52,"int",58,"ptr",0)
    DLLCall("gdi32.dll","int","LineTo","int",$hdc,"int",52,"int",100)
    DLLCall("gdi32.dll","int","MoveToEx","int",$hdc,"int",0,"int",52,"ptr",0)
    DLLCall("gdi32.dll","int","LineTo","int",$hdc,"int",46,"int",52)
    DLLCall("gdi32.dll","int","MoveToEx","int",$hdc,"int",58,"int",52,"ptr",0)
    DLLCall("gdi32.dll","int","LineTo","int",$hdc,"int",100,"int",52)
    DllCall("gdi32.dll","hwnd","SelectObject","int",$hdc,"hwnd",$hPenOld[0])
    DllCall("gdi32.dll","int","DeleteObject","hwnd",$hPen[0])
EndFunc

Func CrossHairsINV(ByRef $hdc)
;~   Local CONST $NOTSRCCOPY = 0x3300087
    DLLCall("gdi32.dll","int","BitBlt","int",$hdc,"int",50,"int",0,"int",5,"int",49,"int",$hdc,"int",50,"int",0,"int",$NOTSRCCOPY)
    DLLCall("gdi32.dll","int","BitBlt","int",$hdc,"int",50,"int",56,"int",5,"int",49,"int",$hdc,"int",50,"int",56,"int",$NOTSRCCOPY)
    DLLCall("gdi32.dll","int","BitBlt","int",$hdc,"int",0,"int",50,"int",49,"int",5,"int",$hdc,"int",0,"int",50,"int",$NOTSRCCOPY)
    DLLCall("gdi32.dll","int","BitBlt","int",$hdc,"int",56,"int",50,"int",44,"int",5,"int",$hdc,"int",56,"int",50,"int",$NOTSRCCOPY)
EndFunc

Func _exit()
    Exit
EndFunc

Updated for version 3.2.10.0

Edited by Nahuel
Link to comment
Share on other sites

Nice work! I really like how you combined all the magnify keyboard movement and pixel/color thing.

I have a few suggestions.

First, for the magnifier I you might want to add something for when the magnifier is trying to get colors from off the screen (i.e. when the mouse is on the top or left side of the screen).

Secondly, I don't know if this is possible or not but I would suggest that in the magnifier you can see the mouse (or at least a representation of the mouse), that would let it be more useful (in my opinion).

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Super job!

Just one problem I can see right now: even with "move cursor with keyb" unchecked, the cursor keys can't be used for their normal function in any app.

The problem is with your Func MouseKeybNO() function.

Instead of setting the Hotkeys to the function "nada" which makes them do nothing, just unset them as follows:

Func MouseKeybNO()
    HotKeySet("+{UP}")
    HotKeySet("{UP}")
    HotKeySet("+{DOWN}")
    HotKeySet("{DOWN}")
    HotKeySet("+{LEFT}")
    HotKeySet("+{LEFT}")
    HotKeySet("{LEFT}")
    HotKeySet("+{RIGHT}")
    HotKeySet("{RIGHT}")
EndFunc

Other than that, love the design and thought you put into pulling it all together.

Any chance of also putting in the separate R,G,B colours in addition to the hex and decimal?

Cheers.

Link to comment
Share on other sites

Very Nice job. :)

Could we have cross hairs on the magnified view, or something to show exactly which pixel we are looking at?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

First, for the magnifier I you might want to add something for when the magnifier is trying to get colors from off the screen (i.e. when the mouse is on the top or left side of the screen).

Yeah, I thought about that too. I'll work on it!

Secondly, I don't know if this is possible or not but I would suggest that in the magnifier you can see the mouse (or at least a representation of the mouse), that would let it be more useful (in my opinion).

Could we have cross hairs on the magnified view, or something to show exactly which pixel we are looking at?

I posted a thread asking for help for how to achieve this, but no-one replied. I asked Larry too and he doesn't know. I really wanted to do that, it'll make the magnifier have an actual purpose.

Instead of setting the Hotkeys to the function "nada" which makes them do nothing, just unset them as follows:

Func MouseKeybNO()
    HotKeySet("+{UP}")
    HotKeySet("{UP}")
    HotKeySet("+{DOWN}")
    HotKeySet("{DOWN}")
    HotKeySet("+{LEFT}")
    HotKeySet("+{LEFT}")
    HotKeySet("{LEFT}")
    HotKeySet("+{RIGHT}")
    HotKeySet("{RIGHT}")
EndFunc
Oh thanks a lot! I did notice that you can't use the keyboard arrows even when the option is unchecked but I didn't know how to fix it, hehe.

Thanks everyone! I'll work on your suggestions.

Link to comment
Share on other sites

UPDATE

  • Added crosshairs to magnifier. (Now you can search pixel by pixel. It's easier if you combine magnifier+move cursor with keyboard.)
  • Fixed problem with HotKeySet (thanks ResNullius)

To do:

  • Avoid magnifier to disappear when it reaches screen edges. - DONE
Edited by Nahuel
Link to comment
Share on other sites

Update 2:

  • Added inverted/solid/none crosshair option.
  • Set magnfier as always on top (When you click on an option the magnifier doesn't lose focus)

give choice inverted or solid crosshair

Done :)

Very Nice...

... noticed that the "freeze" does not freeze the GUI / info ????

8)

Hum.. it does to me... :S

Link to comment
Share on other sites

Hum.. it does to me... :S

Hmmm, yes it does

... gotta love this one

I have extra icon keys for my SciTe

Posted Image

I run the program by clicking the spaceship ( first from left )

Then I want to use the magnifier and find a specific color in the orange icon ( third from left )

I click it and press "pause"..

I move the mouse and I see your script telling me the x, Y and colors still, it appeared that it did not freeze...

only after your post i did everthing exactly the same as above, Thats when I noticed that by clicking the orange icon, that is the SciTe syntax check and it actually "ran" your script a second time

of course it over-layed the original.... dah!!! :)

.... maybe you would like to add a Singleton() or similar

lol, thanks for a great prog

8)

NEWHeader1.png

Link to comment
Share on other sites

Awwwwww!!!! Nice Job!!!! I just finished up my first attempt at this. Not as nice as yours. I did dock my magnification in the gui though, but havent sit down to work out how it doesnt bug up when you are using the "active window" option. Anyhow... here is my script. I like yours.

#NoTrayIcon
#include <GUIConstants.au3>

Global $Paused
Global $version = "2"
Global $SRCCOPY = 0x00CC0020

HotKeySet("{PAUSE}", "TogglePause")

$Picker = GUICreate("Picker " & $version, 180, 450, -1, -1, -1, $WS_EX_TOPMOST)



GUICtrlCreateGroup(" Mouse Coordinates ", 10, 10, 160, 50)
GUICtrlCreateLabel("X:", 25, 33, 15, 15)
$MousePosX = GUICtrlCreateInput("", 40, 30, 40, 20, $ES_READONLY)
GUICtrlCreateLabel("Y:", 90, 33, 15, 15)
$MousePosY = GUICtrlCreateInput("", 105, 30, 40, 20, $ES_READONLY)

GUICtrlCreateGroup(" Color Data ", 10, 70, 160, 110)
GUICtrlCreateLabel("Decimal:", 25, 93, 50, 15)
$DISP_DEC = GUICtrlCreateInput("", 80, 90, 70, 20, $ES_READONLY)
GUICtrlCreateLabel("Hex:", 25, 123, 50, 15)
$DISP_HEX = GUICtrlCreateInput("", 80, 120, 70, 20,$ES_READONLY)
GUICtrlCreateLabel("Color:", 25, 153, 50, 15)
$DISP_COLOR = GUICtrlCreateLabel("", 80, 150, 70, 20,$ES_READONLY)

GUICtrlCreateGroup(" Coordinate Options ", 10, 190, 160, 90)
$RB_Full = GUICtrlCreateRadio(" Full Screen", 25, 210, 100, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$RB_Window = GUICtrlCreateRadio(" Active Window", 25, 230, 100, 20)
GUICtrlCreateLabel("Window:", 25, 255, 50, 15)
$Window = GUICtrlCreateLabel("(full screen)", 75, 255, 70, 15)


GUICtrlCreateLabel("Press PAUSE to freeze/unfreeze.", 0, 285 ,180, 15, $SS_CENTER)
GUICtrlSetColor(-1,0x00808080)

GUICtrlCreateGraphic(5, 300, 170, 1, $SS_ETCHEDFRAME)

$GFX1 = GUICtrlCreateGraphic(20, 372, 140, 1, $SS_ETCHEDFRAME)

$GFX2 = GUICtrlCreateGraphic(92, 300, 1, 140, $SS_ETCHEDFRAME)

$Warning = GUICtrlCreateLabel(" Magnify not available in ACTIVE WINDOW Mode.", 20, 355, 140, 30, $SS_CENTER)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState()

$MyhWnd = GUICreate("Magnify", 100, 100, 40, 320, BitOR($WS_CHILD, $WS_TABSTOP), -1, $Picker)

GUISetState()


While 1
    $msg = GUIGetMsg()
    GetColor()
    If GUICtrlRead($RB_Full) = $GUI_CHECKED Then
        GUISetState(@SW_SHOW, $MyhWnd)
        GUICtrlSetState($Warning, $GUI_HIDE)
        MAG()
    Else
        GUISetState(@SW_HIDE, $MyhWnd)
        GUICtrlSetState($Warning, $GUI_SHOW)
    EndIf
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Func GetColor()
    Sleep(15)
    If GUICtrlRead($RB_Full) = $GUI_CHECKED Then
        Opt("MouseCoordMode", 1)
        Opt("PixelCoordMode", 1)
        GUICtrlSetData($Window, "(full screen)")
        $pos = MouseGetPos()
        $color = PixelGetColor($pos[0],$pos[1])
        GUICtrlSetData($MousePosX, $pos[0])
        GUICtrlSetData($MousePosY, $pos[1])
        GUICtrlSetData($DISP_DEC,$color)
        $HEX6 = StringRight(Hex($color),6)
        GUICtrlSetData($DISP_HEX,"0x" & $HEX6)
        GUICtrlSetBkColor($DISP_COLOR,"0x" & Hex($color))
    Else
        Opt("MouseCoordMode", 0)
        Opt("PixelCoordMode", 0)
        GUICtrlSetData($Window, WinGetTitle(""))
        $win = WinGetPos("")
        $pos=MouseGetPos()
        If $pos[0] >= 0 And $pos[0] <= $win[2] and $pos[1] >= 0 And $pos[1] <= $win[3] Then
            $color=PixelGetColor($pos[0],$pos[1])
            GUICtrlSetData($MousePosX, $pos[0])
            GUICtrlSetData($MousePosY, $pos[1])
            GUICtrlSetData($DISP_DEC,$color)
            $HEX6=StringRight(Hex($color),6)
            GUICtrlSetData($DISP_HEX,"0x" & $HEX6)
            GUICtrlSetBkColor($DISP_COLOR,"0x" & Hex($color))
        Else
            GUICtrlSetData($MousePosX, "----")
            GUICtrlSetData($MousePosY, "----")
            GUICtrlSetData($DISP_DEC,"")
            GUICtrlSetData($DISP_HEX,"")
            GUICtrlSetBkColor($DISP_COLOR, 0xE0DFE3)
        EndIf
    EndIf
EndFunc

Func MAG()
  $MyHDC = DLLCall("user32.dll","int","GetDC","hwnd",$MyhWnd)
  If @error Then Return
  $DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0)
  If Not @error Then
     $xy = MouseGetPos()
     If Not @error Then
        $l = $xy[0]-10
        $t = $xy[1]-10
        DLLCall("gdi32.dll","int","StretchBlt","int",$MyHDC[0],"int", 0,"int",0,"int",100,"int",100,"int",$DeskHDC[0],"int", $l,"int",$t,"int",20,"int",20,"long",$SRCCOPY)
     EndIf
     DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0)
  EndIf
  DLLCall("user32.dll","int","ReleaseDC","int",$MyHDC[0],"hwnd",$MyhWnd)
EndFunc

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(10)
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $Menu_About
                Disp_About()
        EndSelect
    WEnd
EndFunc

Yours is pretty cool with the crosshairs. Nice.

Link to comment
Share on other sites

Awwwwww!!!! Nice Job!!!! I just finished up my first attempt at this. Not as nice as yours. I did dock my magnification in the gui though, but havent sit down to work out how it doesnt bug up when you are using the "active window" option. Anyhow... here is my script. I like yours.

#NoTrayIcon
#include <GUIConstants.au3>

Global $Paused
Global $version = "2"
Global $SRCCOPY = 0x00CC0020

HotKeySet("{PAUSE}", "TogglePause")

$Picker = GUICreate("Picker " & $version, 180, 450, -1, -1, -1, $WS_EX_TOPMOST)
GUICtrlCreateGroup(" Mouse Coordinates ", 10, 10, 160, 50)
GUICtrlCreateLabel("X:", 25, 33, 15, 15)
$MousePosX = GUICtrlCreateInput("", 40, 30, 40, 20, $ES_READONLY)
GUICtrlCreateLabel("Y:", 90, 33, 15, 15)
$MousePosY = GUICtrlCreateInput("", 105, 30, 40, 20, $ES_READONLY)

GUICtrlCreateGroup(" Color Data ", 10, 70, 160, 110)
GUICtrlCreateLabel("Decimal:", 25, 93, 50, 15)
$DISP_DEC = GUICtrlCreateInput("", 80, 90, 70, 20, $ES_READONLY)
GUICtrlCreateLabel("Hex:", 25, 123, 50, 15)
$DISP_HEX = GUICtrlCreateInput("", 80, 120, 70, 20,$ES_READONLY)
GUICtrlCreateLabel("Color:", 25, 153, 50, 15)
$DISP_COLOR = GUICtrlCreateLabel("", 80, 150, 70, 20,$ES_READONLY)

GUICtrlCreateGroup(" Coordinate Options ", 10, 190, 160, 90)
$RB_Full = GUICtrlCreateRadio(" Full Screen", 25, 210, 100, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$RB_Window = GUICtrlCreateRadio(" Active Window", 25, 230, 100, 20)
GUICtrlCreateLabel("Window:", 25, 255, 50, 15)
$Window = GUICtrlCreateLabel("(full screen)", 75, 255, 70, 15)
GUICtrlCreateLabel("Press PAUSE to freeze/unfreeze.", 0, 285 ,180, 15, $SS_CENTER)
GUICtrlSetColor(-1,0x00808080)

GUICtrlCreateGraphic(5, 300, 170, 1, $SS_ETCHEDFRAME)

$GFX1 = GUICtrlCreateGraphic(20, 372, 140, 1, $SS_ETCHEDFRAME)

$GFX2 = GUICtrlCreateGraphic(92, 300, 1, 140, $SS_ETCHEDFRAME)

$Warning = GUICtrlCreateLabel(" Magnify not available in ACTIVE WINDOW Mode.", 20, 355, 140, 30, $SS_CENTER)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState()

$MyhWnd = GUICreate("Magnify", 100, 100, 40, 320, BitOR($WS_CHILD, $WS_TABSTOP), -1, $Picker)

GUISetState()
While 1
    $msg = GUIGetMsg()
    GetColor()
    If GUICtrlRead($RB_Full) = $GUI_CHECKED Then
        GUISetState(@SW_SHOW, $MyhWnd)
        GUICtrlSetState($Warning, $GUI_HIDE)
        MAG()
    Else
        GUISetState(@SW_HIDE, $MyhWnd)
        GUICtrlSetState($Warning, $GUI_SHOW)
    EndIf
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Func GetColor()
    Sleep(15)
    If GUICtrlRead($RB_Full) = $GUI_CHECKED Then
        Opt("MouseCoordMode", 1)
        Opt("PixelCoordMode", 1)
        GUICtrlSetData($Window, "(full screen)")
        $pos = MouseGetPos()
        $color = PixelGetColor($pos[0],$pos[1])
        GUICtrlSetData($MousePosX, $pos[0])
        GUICtrlSetData($MousePosY, $pos[1])
        GUICtrlSetData($DISP_DEC,$color)
        $HEX6 = StringRight(Hex($color),6)
        GUICtrlSetData($DISP_HEX,"0x" & $HEX6)
        GUICtrlSetBkColor($DISP_COLOR,"0x" & Hex($color))
    Else
        Opt("MouseCoordMode", 0)
        Opt("PixelCoordMode", 0)
        GUICtrlSetData($Window, WinGetTitle(""))
        $win = WinGetPos("")
        $pos=MouseGetPos()
        If $pos[0] >= 0 And $pos[0] <= $win[2] and $pos[1] >= 0 And $pos[1] <= $win[3] Then
            $color=PixelGetColor($pos[0],$pos[1])
            GUICtrlSetData($MousePosX, $pos[0])
            GUICtrlSetData($MousePosY, $pos[1])
            GUICtrlSetData($DISP_DEC,$color)
            $HEX6=StringRight(Hex($color),6)
            GUICtrlSetData($DISP_HEX,"0x" & $HEX6)
            GUICtrlSetBkColor($DISP_COLOR,"0x" & Hex($color))
        Else
            GUICtrlSetData($MousePosX, "----")
            GUICtrlSetData($MousePosY, "----")
            GUICtrlSetData($DISP_DEC,"")
            GUICtrlSetData($DISP_HEX,"")
            GUICtrlSetBkColor($DISP_COLOR, 0xE0DFE3)
        EndIf
    EndIf
EndFunc

Func MAG()
  $MyHDC = DLLCall("user32.dll","int","GetDC","hwnd",$MyhWnd)
  If @error Then Return
  $DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0)
  If Not @error Then
     $xy = MouseGetPos()
     If Not @error Then
        $l = $xy[0]-10
        $t = $xy[1]-10
        DLLCall("gdi32.dll","int","StretchBlt","int",$MyHDC[0],"int", 0,"int",0,"int",100,"int",100,"int",$DeskHDC[0],"int", $l,"int",$t,"int",20,"int",20,"long",$SRCCOPY)
     EndIf
     DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0)
  EndIf
  DLLCall("user32.dll","int","ReleaseDC","int",$MyHDC[0],"hwnd",$MyhWnd)
EndFunc

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(10)
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $Menu_About
                Disp_About()                   <<<<<<<<<<<<<<<<<<<<<<<<
        EndSelect
    WEnd
EndFunc

Yours is pretty cool with the crosshairs. Nice.

You need to check your code.... there is no Disp_About() function for it to call.

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Link to comment
Share on other sites

Edit: No more Reduced flicker.

;  http://www.autoitscript.com/forum/index.php?s=&showtopic=53471&view=findpost&p=405026


#include <GUIConstants.au3>

Global $Paused
Global $version = "2"
Global $SRCCOPY = 0x00CC0020

HotKeySet("{PAUSE}", "TogglePause")

$Picker = GUICreate("Picker " & $version, 180, 450, -1, -1, -1, $WS_EX_TOPMOST)



GUICtrlCreateGroup(" Mouse Coordinates ", 10, 10, 160, 50)
GUICtrlCreateLabel("X:", 25, 33, 15, 15)
$MousePosX = GUICtrlCreateInput("", 40, 30, 40, 20, $ES_READONLY)
GUICtrlCreateLabel("Y:", 90, 33, 15, 15)
$MousePosY = GUICtrlCreateInput("", 105, 30, 40, 20, $ES_READONLY)

GUICtrlCreateGroup(" Color Data ", 10, 70, 160, 110)
GUICtrlCreateLabel("Decimal:", 25, 93, 50, 15)
$DISP_DEC = GUICtrlCreateInput("", 80, 90, 70, 20, $ES_READONLY)
GUICtrlCreateLabel("Hex:", 25, 123, 50, 15)
$DISP_HEX = GUICtrlCreateInput("", 80, 120, 70, 20,$ES_READONLY)
GUICtrlCreateLabel("Color:", 25, 153, 50, 15)
$DISP_COLOR = GUICtrlCreateLabel("", 80, 150, 70, 20,$ES_READONLY)

GUICtrlCreateGroup(" Coordinate Options ", 10, 190, 160, 90)
$RB_Full = GUICtrlCreateRadio(" Full Screen", 25, 210, 100, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$RB_Window = GUICtrlCreateRadio(" Active Window", 25, 230, 100, 20)
GUICtrlCreateLabel("Window:", 25, 255, 50, 15)
$Window = GUICtrlCreateLabel("(full screen)", 75, 255, 70, 15)


GUICtrlCreateLabel("Press PAUSE to freeze/unfreeze.", 0, 285 ,180, 15, $SS_CENTER)
GUICtrlSetColor(-1,0x00808080)

GUICtrlCreateGraphic(5, 300, 170, 1, $SS_ETCHEDFRAME)

$GFX1 = GUICtrlCreateGraphic(20, 372, 140, 1, $SS_ETCHEDFRAME)

$GFX2 = GUICtrlCreateGraphic(92, 300, 1, 140, $SS_ETCHEDFRAME)

$Warning = GUICtrlCreateLabel(" Magnify not available in ACTIVE WINDOW Mode.", 20, 355, 140, 30, $SS_CENTER)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState()

$MyhWnd = GUICreate("Magnify", 100, 100, 40, 320, BitOR($WS_CHILD, $WS_TABSTOP), -1, $Picker)

GUISetState()


While 1
    $msg = GUIGetMsg()
    GetColor()
    If GUICtrlRead($RB_Full) = $GUI_CHECKED Then
        GUISetState(@SW_SHOW, $MyhWnd)
        GUICtrlSetState($Warning, $GUI_HIDE)
        MAG()
    Else
        GUISetState(@SW_HIDE, $MyhWnd)
        GUICtrlSetState($Warning, $GUI_SHOW)
    EndIf
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
    Sleep(50)
WEnd

Func GetColor()
    Sleep(10)
    If GUICtrlRead($RB_Full) = $GUI_CHECKED Then
        Opt("MouseCoordMode", 1)
        Opt("PixelCoordMode", 1)
        GUICtrlSetData($Window, "(full screen)")
        $pos = MouseGetPos()
        $color = PixelGetColor($pos[0],$pos[1])
        GUICtrlSetData($MousePosX, $pos[0])
        GUICtrlSetData($MousePosY, $pos[1])
        GUICtrlSetData($DISP_DEC,$color)
        $HEX6 = StringRight(Hex($color),6)
        GUICtrlSetData($DISP_HEX,"0x" & $HEX6)
        GUICtrlSetBkColor($DISP_COLOR,"0x" & Hex($color))
    Else
        Opt("MouseCoordMode", 0)
        Opt("PixelCoordMode", 0)
        GUICtrlSetData($Window, WinGetTitle(""))
        $win = WinGetPos("")
        $pos=MouseGetPos()
        If $pos[0] >= 0 And $pos[0] <= $win[2] and $pos[1] >= 0 And $pos[1] <= $win[3] Then
            $color=PixelGetColor($pos[0],$pos[1])
            GUICtrlSetData($MousePosX, $pos[0])
            GUICtrlSetData($MousePosY, $pos[1])
            GUICtrlSetData($DISP_DEC,$color)
            $HEX6=StringRight(Hex($color),6)
            GUICtrlSetData($DISP_HEX,"0x" & $HEX6)
            GUICtrlSetBkColor($DISP_COLOR,"0x" & Hex($color))
        Else
            GUICtrlSetData($MousePosX, "----")
            GUICtrlSetData($MousePosY, "----")
            GUICtrlSetData($DISP_DEC,"")
            GUICtrlSetData($DISP_HEX,"")
            GUICtrlSetBkColor($DISP_COLOR, 0xE0DFE3)
        EndIf
    EndIf
EndFunc

Func MAG()
  $MyHDC = DLLCall("user32.dll","int","GetDC","hwnd",$MyhWnd)
  If @error Then Return
  $DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0)
  If Not @error Then
     $xy = MouseGetPos()
     If Not @error Then
        $l = $xy[0]-10
        $t = $xy[1]-10
        DLLCall("gdi32.dll","int","StretchBlt","int",$MyHDC[0],"int", 0,"int",0,"int",100,"int",100,"int",$DeskHDC[0],"int", $l,"int",$t,"int",20,"int",20,"long",$SRCCOPY)
     EndIf
     DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0)
  EndIf
  DLLCall("user32.dll","int","ReleaseDC","int",$MyHDC[0],"hwnd",$MyhWnd)
EndFunc

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(10)
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
        EndSelect
    WEnd
   EndFunc
Edited by Fossil Rock

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Link to comment
Share on other sites

Awwwwww!!!! Nice Job!!!! I just finished up my first attempt at this. Not as nice as yours. Anyhow... here is my script. I like yours.

#NoTrayIcon
#include <GUIConstants.au3>

Global $Paused
Global $version = "2"
Global $SRCCOPY = 0x00CC0020

HotKeySet("{PAUSE}", "TogglePause")

$Picker = GUICreate("Picker " & $version, 180, 450, -1, -1, -1, $WS_EX_TOPMOST)
GUICtrlCreateGroup(" Mouse Coordinates ", 10, 10, 160, 50)
GUICtrlCreateLabel("X:", 25, 33, 15, 15)
$MousePosX = GUICtrlCreateInput("", 40, 30, 40, 20, $ES_READONLY)
GUICtrlCreateLabel("Y:", 90, 33, 15, 15)
$MousePosY = GUICtrlCreateInput("", 105, 30, 40, 20, $ES_READONLY)

GUICtrlCreateGroup(" Color Data ", 10, 70, 160, 110)
GUICtrlCreateLabel("Decimal:", 25, 93, 50, 15)
$DISP_DEC = GUICtrlCreateInput("", 80, 90, 70, 20, $ES_READONLY)
GUICtrlCreateLabel("Hex:", 25, 123, 50, 15)
$DISP_HEX = GUICtrlCreateInput("", 80, 120, 70, 20,$ES_READONLY)
GUICtrlCreateLabel("Color:", 25, 153, 50, 15)
$DISP_COLOR = GUICtrlCreateLabel("", 80, 150, 70, 20,$ES_READONLY)

GUICtrlCreateGroup(" Coordinate Options ", 10, 190, 160, 90)
$RB_Full = GUICtrlCreateRadio(" Full Screen", 25, 210, 100, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$RB_Window = GUICtrlCreateRadio(" Active Window", 25, 230, 100, 20)
GUICtrlCreateLabel("Window:", 25, 255, 50, 15)
$Window = GUICtrlCreateLabel("(full screen)", 75, 255, 70, 15)
GUICtrlCreateLabel("Press PAUSE to freeze/unfreeze.", 0, 285 ,180, 15, $SS_CENTER)
GUICtrlSetColor(-1,0x00808080)

GUICtrlCreateGraphic(5, 300, 170, 1, $SS_ETCHEDFRAME)

$GFX1 = GUICtrlCreateGraphic(20, 372, 140, 1, $SS_ETCHEDFRAME)

$GFX2 = GUICtrlCreateGraphic(92, 300, 1, 140, $SS_ETCHEDFRAME)

$Warning = GUICtrlCreateLabel(" Magnify not available in ACTIVE WINDOW Mode.", 20, 355, 140, 30, $SS_CENTER)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState()

$MyhWnd = GUICreate("Magnify", 100, 100, 40, 320, BitOR($WS_CHILD, $WS_TABSTOP), -1, $Picker)

GUISetState()
While 1
    $msg = GUIGetMsg()
    GetColor()
    If GUICtrlRead($RB_Full) = $GUI_CHECKED Then
        GUISetState(@SW_SHOW, $MyhWnd)
        GUICtrlSetState($Warning, $GUI_HIDE)
        MAG()
    Else
        GUISetState(@SW_HIDE, $MyhWnd)
        GUICtrlSetState($Warning, $GUI_SHOW)
    EndIf
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Func GetColor()
    Sleep(15)
    If GUICtrlRead($RB_Full) = $GUI_CHECKED Then
        Opt("MouseCoordMode", 1)
        Opt("PixelCoordMode", 1)
        GUICtrlSetData($Window, "(full screen)")
        $pos = MouseGetPos()
        $color = PixelGetColor($pos[0],$pos[1])
        GUICtrlSetData($MousePosX, $pos[0])
        GUICtrlSetData($MousePosY, $pos[1])
        GUICtrlSetData($DISP_DEC,$color)
        $HEX6 = StringRight(Hex($color),6)
        GUICtrlSetData($DISP_HEX,"0x" & $HEX6)
        GUICtrlSetBkColor($DISP_COLOR,"0x" & Hex($color))
    Else
        Opt("MouseCoordMode", 0)
        Opt("PixelCoordMode", 0)
        GUICtrlSetData($Window, WinGetTitle(""))
        $win = WinGetPos("")
        $pos=MouseGetPos()
        If $pos[0] >= 0 And $pos[0] <= $win[2] and $pos[1] >= 0 And $pos[1] <= $win[3] Then
            $color=PixelGetColor($pos[0],$pos[1])
            GUICtrlSetData($MousePosX, $pos[0])
            GUICtrlSetData($MousePosY, $pos[1])
            GUICtrlSetData($DISP_DEC,$color)
            $HEX6=StringRight(Hex($color),6)
            GUICtrlSetData($DISP_HEX,"0x" & $HEX6)
            GUICtrlSetBkColor($DISP_COLOR,"0x" & Hex($color))
        Else
            GUICtrlSetData($MousePosX, "----")
            GUICtrlSetData($MousePosY, "----")
            GUICtrlSetData($DISP_DEC,"")
            GUICtrlSetData($DISP_HEX,"")
            GUICtrlSetBkColor($DISP_COLOR, 0xE0DFE3)
        EndIf
    EndIf
EndFunc

Func MAG()
  $MyHDC = DLLCall("user32.dll","int","GetDC","hwnd",$MyhWnd)
  If @error Then Return
  $DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0)
  If Not @error Then
     $xy = MouseGetPos()
     If Not @error Then
        $l = $xy[0]-10
        $t = $xy[1]-10
        DLLCall("gdi32.dll","int","StretchBlt","int",$MyHDC[0],"int", 0,"int",0,"int",100,"int",100,"int",$DeskHDC[0],"int", $l,"int",$t,"int",20,"int",20,"long",$SRCCOPY)
     EndIf
     DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0)
  EndIf
  DLLCall("user32.dll","int","ReleaseDC","int",$MyHDC[0],"hwnd",$MyhWnd)
EndFunc

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(10)
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $Menu_About
                Disp_About()
        EndSelect
    WEnd
EndFunc

Yours is pretty cool with the crosshairs. Nice.

Funny how you used my script as a base and then I used yours, haha. I really like yours as well, the magnifier looks great there.e

I did dock my magnification in the gui though, but havent sit down to work out how it doesnt bug up when you are using the "active window" option.

It does! Notice that I disabled the option 'active window' for when the magnify option is activated. Edited by Nahuel
Link to comment
Share on other sites

Ok, so I grabbed a couple of other users' scripts and updated my Screen Color Picker tool.

Functions I added:

*Magnify Under Mouse (by Larry) for more precision.

*Move cursor with keyboard (By Monamor) for more precision.

*Use for Active window only or full screen (By xwinterx)

*Sniff* My arch-enemy clone Monamor gets my credit :)

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

  • 1 year later...

Anyone can help me ?

can't compile source and not pass syntax check also with autoit-v3.2.13.7-beta-setup.exe used...

---------------------------

AutoIt Error

---------------------------

Line 21 (File "C:\Documents and Settings\a.xyxzzwe\Desktop\Nuovo Docu.au3"):

GUICreate("Pixel Color", 180, 410,0, 0, -1, $WS_EX_TOPMOST)

GUICreate("Pixel Color", 180, 410,0, 0, -1, ^ ERROR

Error: Variable used without being declared.

---------------------------

OK

---------------------------

thank you,

m.

Edited by myspacee
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...