Sign in to follow this  
Followers 0
Buckw1

Color checking

5 posts in this topic

Hi,

I'll try to describe my issue to the best of my ability and I have searched thru the forums without any solution.

imagine a life or energy check in the game of your choice, it is a circle full of various shades of orange (constantly changing) when good. The orange decreases in the manner of a radar screen trace ( a spiral? ) The background color is grayish but agains varies somewhat. I want to make a script that monitors how much orange is left. I have tried pixelcolor, it fails, pixelsearch is better but still fails over 75% of the time. My current experiment will be pixelchecksum. From my tests it appears light colors are high value and dark colors are lower. I'll test this later tonite....

If this fails can the master here please toss around some other ideas....

Buck

Share this post


Link to post
Share on other sites



Hi,

I'll try to describe my issue to the best of my ability and I have searched thru the forums without any solution.

imagine a life or energy check in the game of your choice, it is a circle full of various shades of orange (constantly changing) when good. The orange decreases in the manner of a radar screen trace ( a spiral? ) The background color is grayish but agains varies somewhat. I want to make a script that monitors how much orange is left. I have tried pixelcolor, it fails, pixelsearch is better but still fails over 75% of the time. My current experiment will be pixelchecksum. From my tests it appears light colors are high value and dark colors are lower. I'll test this later tonite....

If this fails can the master here please toss around some other ideas....

Buck

Here is what you do, Open up Autoit Info Tool(Came with Autoit) and run it, then run your game, when the health bar or whatever is the desired color for when you want it to take action, move you mouse over where it is and press Ctrl+Alt+F (this pauses info display) then minimize/close the game open up this browser and post a reply of the HEX color that you see in the window info tool, along with the pixel coordinates.

Then you will be able to "pixelgetcolor" that pixel, and if that color value is equal to the desired color, then it presses you health potion button or whatever you want it to do

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

As noted in my post, the color values are not stable, the good value ranges from 10,000,000, to 16,000,000 with the bad value usually 10 mil and lower.

Pixelgetcolor and pixelcolorsearch would both give false positive results.

Edit a bit later after further testing.

Problem solved, i forgot I could make the game widescreen which gives me a nice black background and much more stable colors, now I can use pixel color search! One of those DOH! moments :D

Edited by Buckw1

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

If your constant is the background being a "shade" of grey, then use PixelSearch() with shade variation on the background only, unfortunately, I don't think you can go Right to Left, and are forced to go Left to Right... So you could set up a For/Next Loop looping backwards and using those coords in the loop to do your PixelSearch(), maybe something like this:

;================================================================================================
;~  $xEndCoord = Where you would normally start searching with a normal PixelSearch Left To Right
;~  $iWidthToSearch = The Difference in width from where you start to where you end
;~  $yConstantCoord = We are searching a straight line, so the y coord will not change
;~  $iColor = The shade of grey to search
;~  $iShade = The number of shades of grey to search
;~  $iStep = The number of pixels to skip at a time during the search
;================================================================================================

$Search = _ReversePixSearch(300, 100, 20, 0xCCCCCC, 15, 2)

Func _ReversePixSearch($xEndCoord, $iWidthToSearch, $yConstantCoord, $iColor, $iShade, $iStep)
    For $xCoord = $iWidthToSearch + $xEndCoord To $xEndCoord Step - $iStep
        $PixSearch = PixelSearch($xCoord, $yConstantCoord, $xCoord, $yConstantCoord, $iColor, $iShade)
        If IsArray($PixSearch) Then Return $PixSearch
    Next
EndFunc

Edit:

Had Right To Left in comment rather than Left To Right

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

If your constant is the background being a "shade" of grey, then use PixelSearch() with shade variation on the background only, unfortunately, I don't think you can go Right to Left, and are forced to go Left to Right... So you could set up a For/Next Loop looping backwards and using those coords in the loop to do your PixelSearch(), maybe something like this:

;================================================================================================
;~  $xEndCoord = Where you would normally start searching with a normal PixelSearch Right To Left
;~  $iWidthToSearch = The Difference in width from where you start to where you end
;~  $yConstantCoord = We are searching a straight line, so the y coord will not change
;~  $iColor = The shade of grey to search
;~  $iShade = The number of shades of grey to search
;~  $iStep = The number of pixels to skip at a time during the search
;================================================================================================

$Search = _ReversePixSearch(300, 100, 20, 0xCCCCCC, 15, 2)

Func _ReversePixSearch($xEndCoord, $iWidthToSearch, $yConstantCoord, $iColor, $iShade, $iStep)
    For $xCoord = $iWidthToSearch + $xEndCoord To $xEndCoord Step - $iStep
        $PixSearch = PixelSearch($xCoord, $yConstantCoord, $xCoord, $yConstantCoord, $iColor, $iShade)
        If IsArray($PixSearch) Then Return $PixSearch
    Next
EndFunc

I was actually testing for the grey color when I stumbled across my widescreen option. Testing for grey worked and your code is more refined and faster than mine was!

Thanks Guys

Buck

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