PIXEL FINDER ( Pixel Rect + GUI)
----------------------------------------------------
Now, I looking for a script maded by Larry about the colors(PIXEL RECT functions)
I had a idea from there, and I wrote this small script adapting Graphic Interface.
* In general: This show a mini-picture/preview from the screen (on mouse movement),
and show color values (HEX, HTML, RGB).
- You can copy some value pressing CTRL + SHIFT + number
*Requirement: AutoIt-GUI v102.18 or later.(tested in v102.18)
(I don't recommend to use in previous versions to v102.17)
Remark: Moving through the images, tends to fail getting wrong preview(Black), still I dunno if is:
- AutoIt (PixelGetColor function) or AutoIt-GUI limitation :huh2:
- Or some wrong code mine. :D
But...copy and test it! :lol:
(GUI is making a difference in AutoIt for do scripts)
Suggestions/Comments are welcome? :)
Sorry, I don't put any screenshot.
----------------------------------------------------
Now, I looking for a script maded by Larry about the colors(PIXEL RECT functions)
I had a idea from there, and I wrote this small script adapting Graphic Interface.
* In general: This show a mini-picture/preview from the screen (on mouse movement),
and show color values (HEX, HTML, RGB).
- You can copy some value pressing CTRL + SHIFT + number
*Requirement: AutoIt-GUI v102.18 or later.(tested in v102.18)
(I don't recommend to use in previous versions to v102.17)
Remark: Moving through the images, tends to fail getting wrong preview(Black), still I dunno if is:
- AutoIt (PixelGetColor function) or AutoIt-GUI limitation :huh2:
- Or some wrong code mine. :D
But...copy and test it! :lol:
(GUI is making a difference in AutoIt for do scripts)
Suggestions/Comments are welcome? :)
Sorry, I don't put any screenshot.
Code:
_PixelFinder()
Func _PixelFinder()
$pixMouse= MouseGetPos()
$curColor = PixelGetColor( $pixMouse[0], $pixMouse[1])
$xScreen= $pixMouse[0]-10
$yScreen= $pixMouse[1]-10
$rectSize= 20
$pixSize= 6
;// FORM ----------------------------------------------
Global $titWin= "Pixel Finder"
Global $YU= GUICreate($titWin, 330, 126, 150, 150)
; ===[ Arranging pixels ]===
$rect = _LoadPixelRect( $xScreen, $yScreen, $xScreen + $rectSize, $yScreen + $rectSize)
$FC= Ubound($rect)
$x= 0
$y= 0
Dim $Lbls[$FC][$FC]
For $a=0 to $FC - 1
For $b=0 to $FC - 1
$Lbls[$a][$b]= GUISetControl("label", "", $x, $y, $pixSize, $pixSize)
GUISetControlEx(-1, -1, "", "", 0x0, $rect[$a][$b])
$x= $x + $pixSize
Next
$y= $y + $pixSize
$x= 0
Next
GUIDefaultFont (8, 400, "verdana", 0)
GUISetControl("group", "", 149, 3, 45, 51)
; ===[ Labels ]===
$selColor= GUISetControl("label", "", 150, 10, 42, 42)
GUISetControlEx(-1, -1, "", "", 0x0, $curColor )
$infoX= GUISetControl("label", "x", 200, 10, 100, 12)
$infoY= GUISetControl("label", "y", 200, 20, 100, 12)
Global $infoTXT= GUISetControl("label", "Copy value (CTRL+SHIFT+#)", 135, 65, 170, 15, 0x1000)
Global $infoCC= GUISetControl("label", "", 305, 65, 18, 15, 0x1000)
$infoHEX= GUISetControl("label", "HEX", 135, 80, 150)
$infoHTML= GUISetControl("label", "HTML", 135, 90, 150)
$infoRGB= GUISetControl("label", "RGB", 135, 100, 150)
;===[ PROCESS START ]====
HotKeySet("^+1", "_CopyHEX")
HotKeySet("^+2", "_CopyHTML")
HotKeySet("^+3", "_CopyRGB")
HotKeySet("{PAUSE}", "_FreezeW")
Global $_pauseSet = 0
While GuiShow() AND GUIMSg(0) <> -3
$pixMouse= MouseGetPos()
$curColor = PixelGetColor( $pixMouse[0], $pixMouse[1])
Global $col_HEX= Hex($curColor, 6)
Global $col_HTML= StringRight($col_hex, 2) & StringMid($col_hex, 3, 2) & StringLeft($col_hex, 2)
Global $col_RGB= _RGB($curColor)
; ===[ Updating info ]===
GUISetControlEx($selColor, -1, "", "", 0x0, $curColor )
GUIWrite($infoX, -1, "X: " & $pixMouse[0])
GUIWrite($infoY, -1, "Y: " & $pixMouse[1])
GUIWrite($infoHEX, -1, "1. HEX: " & $col_HEX)
GUIWrite($infoHTML, -1, "2. HTML: #" & $col_HTML)
GUIWrite($infoRGB, -1, "3. RGB: " & $col_RGB)
If $_PauseSet = 0 then
;// Preview process
$xScreen= $pixMouse[0]-10
$yScreen= $pixMouse[1]-10
$rect = _LoadPixelRect( $xScreen, $yScreen, $xScreen + $rectSize, $yScreen + $rectSize)
$FC= Ubound($rect)
$x= 0
$y= 0
For $a=0 to $FC - 1
For $b=0 to $FC - 1
GUISetControlEx($Lbls[$a][$b], -1, "", "", 0x0, $rect[$a][$b])
$x= $x + $pixSize
Next
$y= $y + $pixSize
$x= 0
Next
EndIf
Wend
EndFunc
Func _CopyHEX()
ClipPut($col_HEX)
GUIWrite($infoTXT, -1, "HEX value copied: " & $col_HEX)
GUISetControlEx($infoCC, -1, "", "", 0x0, DEC($col_HEX))
EndFunc
Func _CopyHTML()
ClipPut($col_HTML)
GUIWrite($infoTXT, -1, "HTML value copied: " & $col_HTML)
GUISetControlEx($infoCC, -1, "", "", 0x0, DEC($col_HEX))
EndFunc
Func _CopyRGB()
ClipPut($col_RGB)
GUIWrite($infoTXT, -1, "RGB copied: " & $col_RGB)
GUISetControlEx($infoCC, -1, "", "", 0x0, DEC($col_HEX))
EndFunc
Func _FreezeW()
If $_PauseSet = 0 then
Global $_PauseSet = 1
WinSetTitle($titWin, "", $titWin & " (freeze) ")
else
Global $_PauseSet = 0
WinSetTitle($titWin, "", $titWin)
EndIf
EndFunc
; _LoadPixelRect: maded by Lar. (thanks)
Func _LoadPixelRect($_NL, $_NT, $_NR, $_NB)
If ($_NL > $_NR Or $_NT > $_NB) Then
SetError(1)
Return 0
EndIf
Dim $_APIXRECT[$_NB-$_NT+1][$_NR-$_NL+1]
For $_NY = $_NT To $_NB
For $_NX = $_NL To $_NR
$_APIXRECT[$_NY-$_NT][$_NX-$_NL] = PixelGetColor($_NX,$_NY)
Next
Next
Return $_APIXRECT
EndFunc
Func _RGB($_DColor)
Local $R= BitAnd( BitShift( $_DColor, 16 ), 0xff )
Local $G= BitAnd( BitShift( $_DColor, 8 ), 0xff )
Local $B= BitAnd( $_DColor, 0xff )
Return "(" & $B & ", " & $G & ", " & $R & ")"
EndFunc