Hi!
Is there a simple way to find the last specified-color pixel in a region, i.e. to search from the lower corners upwards to the upper corners?
I would like to search in an 1 pixel wide region from bottom to top of the region. According to Doc the direction can be changed by coordinates (y1 > y2) only if Slow mode is used. Is there really no way to do the same with the Fast mode?
Thank you very much in advance!
PixelSearch in opposite direction
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
PixelSearch in opposite direction
Last edited by newbieforever on 21 Sep 2017, 07:43, edited 1 time in total.
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: PixelSearch in opposite direction
Is there really no solution for such a simple task?
Re: PixelSearch in opposite direction
ImageGetColors ().ahk detects all colors of an existing image/file.
Means, an image with 1-px width, n-px height would parse a vertical line for its color values.
Search the forum for Gdip.ahk + partial + area + ...
Good luck
Means, an image with 1-px width, n-px height would parse a vertical line for its color values.
Search the forum for Gdip.ahk + partial + area + ...
Good luck
-
- Posts: 493
- Joined: 24 Aug 2016, 03:34
Re: PixelSearch in opposite direction
@BoBo: Thank you very much.
Hm ... I have to search in a program's window, not in an image or file. I suppose there would be a way to make an image from my search area, but ... A little to complicated for me, I think ...
Hm ... I have to search in a program's window, not in an image or file. I suppose there would be a way to make an image from my search area, but ... A little to complicated for me, I think ...
Re: PixelSearch in opposite direction
Two ideas:
[Gdip_ImageSearch]
Use GDI+ to do image search? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 04#p136204
[retrieve pixels as text, 8 characters per pixel, but note, the rows of pixels are retrieved in reverse order]
Gdip: image binary data to hex string for OCR - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=35339
[Gdip_ImageSearch]
Use GDI+ to do image search? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 04#p136204
[retrieve pixels as text, 8 characters per pixel, but note, the rows of pixels are retrieved in reverse order]
Gdip: image binary data to hex string for OCR - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=35339
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: PixelSearch in opposite direction
Hi there,
EDIT:
Never mind, I don't need that solution anymore at the moment.
EDIT END
I had (almost) the same desire. Came up with the code below. (Note that the search here is one dimensional, however, it should be rather easy to extend it to 2 dimensions. Parameter #4 in _get_nextPixelWithColor defines the direction - until the edge of the screen, assuming a one screen PC setup.)
Even though it is faster than the slow PixelSearch in reverse direction, it still is not fast at all.
Does anyone have an idea how to make it faster?
Many thanks in advance.
Regards, S.
EDIT:
Never mind, I don't need that solution anymore at the moment.
EDIT END
I had (almost) the same desire. Came up with the code below. (Note that the search here is one dimensional, however, it should be rather easy to extend it to 2 dimensions. Parameter #4 in _get_nextPixelWithColor defines the direction - until the edge of the screen, assuming a one screen PC setup.)
Even though it is faster than the slow PixelSearch in reverse direction, it still is not fast at all.
Does anyone have an idea how to make it faster?
Many thanks in advance.
Regards, S.
Code: Select all
CoordMode, Mouse, Screen
MouseGetPos, v_out_mouse_X, v_out_mouse_Y
a_pixelFound := _get_nextPixelWithColor("0xRRGGBB", v_out_mouse_X, v_out_mouse_Y, "+x", 100)
if a_pixelFound
MsgBox, % a_pixelFound.X ", " a_pixelFound.Y
else
MsgBox, Not found.
_get_nextPixelWithColor(p_rgb_0xRRGGBB, p_start_X, p_start_Y, p_direction_plusMinusXY, p_stepSizePixel)
{
CoordMode, Pixel, Screen
v_target_X := p_start_X
v_target_Y := p_start_Y
v_targetOutOfScreen := 0
v_increment_X := 0
v_increment_Y := 0
if (InStr(p_direction_plusMinusXY, "x", false))
v_increment_X := p_stepSizePixel
if (InStr(p_direction_plusMinusXY, "y", false))
v_increment_Y := p_stepSizePixel
if (SubStr(p_direction_plusMinusXY, 1, 1) = "-")
{
v_increment_X *= -1
v_increment_Y *= -1
}
PixelGetColor, v_rgb_out, % v_target_X, % v_target_Y, RGB
While ((not v_rgb_out = p_rgb_0xRRGGBB) and (not v_targetOutOfScreen))
{
v_target_X += v_increment_X
v_target_Y += v_increment_Y
if (v_target_X < 0 or v_target_X > A_ScreenWidth or v_target_Y < 0 or v_target_Y > A_ScreenHeight)
{
v_targetOutOfScreen := 1
}
else
{
PixelGetColor, v_rgb_out, % v_target_X, % v_target_Y, RGB
}
}
if (p_stepSizePixel = 1)
if v_targetOutOfScreen
return 0
else
return Object("X", v_target_X, "Y", v_target_Y)
else
return _get_nextPixelWithColor(p_rgb_0xRRGGBB, v_target_X - v_increment_X, v_target_Y - v_increment_Y, p_direction_plusMinusXY, p_stepSizePixel // 2)
}
Who is online
Users browsing this forum: Billykid, Google [Bot] and 186 guests