Read the percentage of a power bar

Ask gaming related questions (AHK v1.1 and older)
henriquehassi
Posts: 24
Joined: 29 Jul 2020, 17:11

Read the percentage of a power bar

Post by henriquehassi » 21 Jan 2022, 07:04

hello everyone, again I turn to the community to learn something new

this image below is youtube video, the script is made in AHK, what impressed me is the accuracy that it returns to % of the character's energy bar
bar percent.png
bar percent.png (1.18 MiB) Viewed 425 times
if in the GUI you put into the software click the work button if it has only 21% or more, it reads the value and performs the action if the percentage is valid.

but how could I do it in such a precise way?

User avatar
boiler
Posts: 16962
Joined: 21 Dec 2014, 02:44

Re: Read the percentage of a power bar

Post by boiler » 21 Jan 2022, 07:10

You can use ImageSearch to find a part of the unfilled-in portion of the power bar, which will tell you the location where the filled-in portion stops because the search is performed left-to-right. See this thread where this approach is discussed in detail. Your situation is even better because the numbers are not overlaid on top of the bar, so you can always be precise about its level.

After finding the position of where the filled in portion ends for each bar, it's just a matter of doing the math of dividing the length of the filled-in portion by the overall length.

henriquehassi
Posts: 24
Joined: 29 Jul 2020, 17:11

Re: Read the percentage of a power bar

Post by henriquehassi » 21 Jan 2022, 07:28

good logic, if we work on it, I find the already worn-out so (if any) as I would to find out exactly the beginning of the bar? since they would be two image search

User avatar
boiler
Posts: 16962
Joined: 21 Dec 2014, 02:44

Re: Read the percentage of a power bar

Post by boiler » 21 Jan 2022, 07:32

I would search for the little cap on the left end of the bar to find its starting location since that doesn’t change colors like the bar does.

Post Reply

Return to “Gaming Help (v1)”