Check the bar length and check every pixel of it

Ask gaming related questions (AHK v1.1 and older)
roofik5
Posts: 23
Joined: 03 Jan 2021, 10:52

Check the bar length and check every pixel of it

Post by roofik5 » 15 Aug 2022, 15:29

Hey, I'm trying to found of how to 'cut' the health bar in parts and check every single part of it.


Here's what I mean:

I have health bar like that
image.png
image.png (10.83 KiB) Viewed 391 times
It has diffrent shade of red color in Y axis and same pixel red colors in X axis, what i want to do is to cut it in parts like this:
image.png
image.png (11.6 KiB) Viewed 391 times
and check if for example in 7th (70% of all bar) part there is any shade of red color. If it is missing then 'bla bla'
image.png
image.png (11.04 KiB) Viewed 391 times
What is the smartest way to find the start of health bar and the end of it? Depending for example of shades of red color?

Of course I can and I did it by get coordinates of exactly 7 part and pixelgetcolor and I can do it, but I'm trying to improve my script and then add some gui to type for example "type % of health bar to happen something [...]" And what is important that health bar can be in diffrent position based on screen resolution etc.

My script for now is like this, but I don't think it could be helpful for this request

Code: Select all

ImageSearch, hXX, hYY, 0, 0, A_ScreenWidth, A_ScreenHeight, *healhInfo.PNG	
PixelGetColor, Check25, % hXX +55,% hYY +30, RGB
		if (Check25 != 0xC234234) {
		
		}
		
It find on the screen "Health info" which is over health bar in upper left corner, move check pixels to te right and down to my specific point, check if the bar on this point is red or the red color is missing. As you can see it's very primitive and not much configurable too fast.

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Check the bar length and check every pixel of it

Post by swagfag » 15 Aug 2022, 19:40

create a ?x1 px image of the topmost strip of red pixels(its unlikely this would change when varying the resolution, but u should double check regardless), ImageSearch for it(this gives u the start of the hp bar), PixelGetColor rightwards until u find the "border pixel"(indicated green, this gives u the end of the hp bar)
image.png
image.png (35.84 KiB) Viewed 365 times

roofik5
Posts: 23
Joined: 03 Jan 2021, 10:52

Re: Check the bar length and check every pixel of it

Post by roofik5 » 16 Aug 2022, 03:21

That's very smart idea

Post Reply

Return to “Gaming Help (v1)”