Sign in to follow this  
Followers 0

_iPixelSearch()

10 posts in this topic

Posted (edited)

i almost know for sure that there is something like this.

but i needed this. and i thought id share it.

syntax is the same as PixelSearch

return[0] = the found pixel color

return[1] = x coord

return[2] = y coord

Func _iPixelSearch($i_left, $i_top, $i_right, $i_bottom, $i_color, $i_shade = 0, $i_step = 1)
    Local $av_ret[3]
    Local $ai_coords = PixelSearch($i_left, $i_top, $i_right, $i_bottom, $i_color, $i_shade, $i_step)
    If @error Then
        Return 0
    EndIf
    $av_ret[0] = PixelGetColor($ai_coords[0], $ai_coords[1])
    $av_ret[1] = $ai_coords[0]
    $av_ret[2] = $ai_coords[1]
    Return $av_ret
EndFunc;==>_iPixelSearch

_iPixelSearch.au3

Edited by w0uter

Share this post


Link to post
Share on other sites



Posted

Oh thank you alot! This is perfect for my collision detection.

Share this post


Link to post
Share on other sites

Posted

I don't understand the use of this function?

Do you have an example?

Share this post


Link to post
Share on other sites

Posted

useless example :(

$v_color = 0xFF0000

$ai_ex = _iPixelSearch(0, 0, @DesktopWidth, @DesktopHeight, $v_color, 100)
$s_ex = 'The difference between the searched color(' & $v_color & ') and the found color(' & $ai_ex[0] & ') is ' & ($v_color - $ai_ex[0])
MsgBox(0, '', $s_ex)

Share this post


Link to post
Share on other sites

Posted

Ah I see :(

Share this post


Link to post
Share on other sites

Posted

I'm overly dense today, I'm not getting the purpose of this baby...

Share this post


Link to post
Share on other sites

Posted

If you search for a color WITH variation, then it returns the color found. This could be used to find a nice average to base your color variation on. I.E. Find the highest variation found, and lowest variation found. Then use that range to make it as efficient as possible.

Share this post


Link to post
Share on other sites

Posted

Ahhh.. gotcha, ok cool. I could see myself making use of that. Although frowned upon I do alot with whatever game I'm currently playing. Some games make it tough to nail down a pixel color that is always the same.

Combine this with a local calibration and allow for +- range on the find and you should be pretty solid.

Share this post


Link to post
Share on other sites

Posted

Some games make it tough to nail down a pixel color that is always the same.

<{POST_SNAPBACK}>

what do you think the shade parameter is for ;P

Share this post


Link to post
Share on other sites

Posted

what do you think the shade parameter is for ;P

<{POST_SNAPBACK}>

have you guys thought of setting the pixel color each time the script is run? - IE: i am currently writing a script that will wait till i give it the mousecoord for the range to search in then the current colors to search for before running the actual loop... thus the shade variance can be much stricter thus hopefully more accurate... then as the colors begin to fail the search just kick off the script again... else more ideal (though beyond my noob abilities) keep an array of the color found to what was origionally matched... thus if the average return is consistantly darker... reset the orig search color accordingly ((figured this would help in cases of slight variation over time, specifically in a game when the pixel color changes from day to night - but don't know how badly that would affect performance.

Anyway don't have anything good enough for yall to at least laugh at, though will post asap... :(

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.