 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
tinku99
Joined: 03 Aug 2007 Posts: 16
|
Posted: Fri Aug 03, 2007 8:22 am Post subject: pixelsearch not this color |
|
|
I would like to be able to exclude certain colors from the search. For example trying to find a pixel that changes depending on what the background is.
I tried using ! in the expression for color in pixelsearch, but it didn't work. |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1356
|
Posted: Fri Aug 03, 2007 5:19 pm Post subject: |
|
|
| post the script that youre using for pixelsearch |
|
| Back to top |
|
 |
tinku99
Joined: 03 Aug 2007 Posts: 16
|
Posted: Mon Dec 31, 2007 3:26 am Post subject: pixelsearch not this color |
|
|
I was trying to make an edge detection program which i did as below.
But I wonder if there is a more efficient way to search until you get to a different color then you are on, perhaps to detect changes in the gui environment.
what i did in the code below is search in 2 pixel increments until i found a color different enough from the one that i start from...
| Code: | d:: ;; lower edge
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
StringLeft, color0, color, 4
Sx := MouseX
Sy := MouseY
counter := 0
loop {
if (counter > 4)
counter := 0
Sx := Sx
Sy := Sy + 1
PixelSearch, Ux, Uy, %Sx%, %Sy%, %Sx%, %Sy%, %color%, 80, Fast
PixelGetColor, colorbw, %Ux%, %Uy%
StringLeft, colorbw2, colorbw, 4
SetFormat, integer, d
colorbw0 := 1 + color0 - 1
if (counter = 0)
{
colorbwa0 := 1 + colorbw2 - 1
}
else if (counter = 1) {
colorbwa1 := 1 + colorbw2 - 1
}
else if (counter = 2) {
colorbwa2 := 1 + colorbw2 - 1
}
else if (counter = 3) {
colorbwa3 := 1 + colorbw2 - 1
}
else if (counter = 4) {
colorbwa4 := 1 + colorbw2 - 1
}
colorbwa := (colorbwa1 + colorbwa2 + colorbwa3 + colorbwa4) / 4
counter := counter + 1
absc := Abs(colorbwa - colorbw0)
if (absc > 40)
break
}
lx := Sx
ly := Sy
MouseMove, %ux%, %uy%
colorbwa =
colorbwa0 =
colorbwa1 =
colorbwa2 =
colorbwa3 =
colorbwa4 =
return
|
|
|
| Back to top |
|
 |
tinku99
Joined: 03 Aug 2007 Posts: 16
|
Posted: Mon Dec 31, 2007 3:50 am Post subject: solved |
|
|
I figured out a better way using the current function
this will first search for a darker color than then a brighter color around the current mouse position and then move to both one by one.
| Code: | F6::
MouseGetPos, MouseX, MouseY
PixelGetColor, colora, %MouseX%, %MouseY%
ax := MouseX - 100
ay := MouseX + 100
sx := MouseX + 100
sy := MouseY + 100
StringLeft, color0, colora, 4
SetFormat, integer, d
colora0 := 1 + color0 - 1
variation := colora0 - 50
variationb := 200 - colora0
PixelSearch, Px, Py, %MouseX%, %MouseY%, %sx%, %sy%, 0x000000, %variation%, Fast
PixelGetColor, colorb, %Px%, %Py%
MouseMove, %Px%, %Py%
Px =
Py =
sleep, 500
PixelSearch, Px, Py, %MouseX%, %MouseY%, %sx%, %sy%, 0xFFFFFF, %variationb%, Fast
MouseMove, %Px%, %Py%
return |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|