PixelSearch search area help

Ask gaming related questions (AHK v1.1 and older)
Saphile
Posts: 7
Joined: 16 Mar 2022, 22:15

PixelSearch search area help

Post by Saphile » 12 Aug 2022, 20:50

Hello, I started using AHK a few months ago to automate some tasks and I'm still learning. I wanted to make a script for a single player game that alerts me of low health, but the health bar is always moving around the screen. I can't search the entire screen because it constantly causes false positives and I can't use image search because it's too inconsistent. I created a quick art demonstration so I can explain what I need help with. I want to be able to create a search area that follows the blue health bar and only searches in this box. And then I'll use the coordinates of the box to do a pixelsearch to test for a positive and alert me.

can anyone help me with understanding how I make this search area and also make it follow the blue healthbar?
Any help is very appreciated.
Attachments
image.png
image.png (81.58 KiB) Viewed 1136 times
image2.png
image2.png (81.16 KiB) Viewed 1136 times

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: PixelSearch search area help

Post by mikeyww » 12 Aug 2022, 21:39

Hi,

You could try :arrow: ImageSearch and then search for pixels nearby.

Saphile
Posts: 7
Joined: 16 Mar 2022, 22:15

Re: PixelSearch search area help

Post by Saphile » 12 Aug 2022, 23:51

mikeyww wrote:
12 Aug 2022, 21:39
Hi,

You could try :arrow: ImageSearch and then search for pixels nearby.
Hello and thank you for your reply.

There is nothing to image search, the health bar always changes. But the colors stay the same. That's why I was wondering how could I have a search area follow the health bar around and then use the search area to coord for my pixelsearch

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: PixelSearch search area help

Post by mikeyww » 13 Aug 2022, 06:05

If the bar & bar's color are constant, then why will ImageSearch fail?

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

Re: PixelSearch search area help

Post by boiler » 13 Aug 2022, 07:31

@Saphile - You seem to be in the mindset of having to search for the entire health bar. What mikeyww is suggesting is that you search for a piece of the health bar that would always be the same, presumably a small section of the left end of it.

Saphile
Posts: 7
Joined: 16 Mar 2022, 22:15

Re: PixelSearch search area help

Post by Saphile » 13 Aug 2022, 14:05

Hello, and thank you for your suggestion.
The health bars colors change slightly based on the lighting in the game, so it's unfortunately not possible to use image search reliably @boiler the only way I can see it working is by having a search area follow the health box around, it would come in handy for me to get this script cause I can add other variables like certain alerts for magic and stamina too.

Saphile
Posts: 7
Joined: 16 Mar 2022, 22:15

Re: PixelSearch search area help

Post by Saphile » 13 Aug 2022, 14:08

@mikeyww I was mistaken, the colors don't actually stay the same hex but to the eye they look the same. The lighting in the game also changes the hue of the health bar ever so slightly so image search doesn't work.


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

Re: PixelSearch search area help

Post by boiler » 13 Aug 2022, 15:44

It's also possible that there is a border around the health bar that is more constant, so it could be found via ImageSearch even if the colors inside of it change. Since you've only showed your rendering, we're just guessing and can only give you limited advice.

Post Reply

Return to “Gaming Help (v1)”