image search help

Ask gaming related questions (AHK v1.1 and older)
michelxd15
Posts: 132
Joined: 08 Aug 2019, 02:02

image search help

Post by michelxd15 » 02 Jun 2020, 05:17

I'm trying to create a script with the image search function and I'm having some problems
I'll put some photos and leave the explanation below

Life Bar Full : https://imgur.com/a/Sk8sk1Q
Life Bar 70% : https://imgur.com/a/dkd6dW7

in the two images below we have one with a full life, and another with a life of 70%
I would like that when life was full, there was no action and that when life gets to be equal to the 70% image, the "R" key should be sent until it is equal to the LifeBar Full image

remembering that the "R" key would activate the function of regaining life in the game!

Ugropuz
Posts: 7
Joined: 02 Jun 2020, 07:59

Re: image search help

Post by Ugropuz » 02 Jun 2020, 08:52

same thing just real others threads... before you making dupe one

michelxd15
Posts: 132
Joined: 08 Aug 2019, 02:02

Re: image search help

Post by michelxd15 » 02 Jun 2020, 10:39

I made the attempt using this code:

Code: Select all

loop
{
	loop, Files, C:\Users\Micheel\Desktop\Healer\*.*
	{
		ImageSearch,,, 1185, 20, 1310, 440, *TransBlack *50 %A_LoopFileFullPath% ; modify variation to account for background
		if !ErrorLevel ; image is found
		{
			ImageSearch, x, y, 1190, 125, 1265, 180, *50 C:\Users\Micheel\Desktop\Healer\LifeBar.png ; make sure path and filename are correct
			if !ErrorLevel ; bar has fallen below desired level
				Send, {r}
                        Sleep, 250
		}
	}
}
this script has not yet verified the two images implanted, only the Full Life image, and I have a problem when the script checks Full Life
when life is full instead of ignoring and taking no action he fires the "R" key

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

Re: image search help

Post by swagfag » 02 Jun 2020, 11:00

u can do it with 2 timers

Code: Select all

SetTimer checkIfHpBelow70

checkIfHpBelow70() {
	if !pixelEquals(???, ???, 0xDB4F4F) ; below 70%
	{
		SetTimer, , Off ; turn this timer off
		SetTimer spamKeyUntilHpIs100
	}
}

spamKeyUntilHpIs100() {
	if !pixelEquals(???, ???, 0xDB4F4F) ; below 100%
		Send r
	else
	{
		SetTimer, , Off ; turn this timer off
		SetTimer checkIfHpBelow70
	}
}

pixelEquals(x, y, rgb) {
	PixelGetColor color, x, y, RGB
	return color = rgb
}
and sampling 2 pixels
Image

michelxd15
Posts: 132
Joined: 08 Aug 2019, 02:02

Re: image search help

Post by michelxd15 » 04 Jun 2020, 18:37

@swagfag
only one problem or game has a protection where a black screen is and after 5 minutes open and all as the screen's cores stay at 0x000000 even 0xDB4F4F

i use a script that uses pixel verification and it stopped working. for this reason i am looking to make an image using image search but i am not very familiar with this function

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

Re: image search help

Post by swagfag » 04 Jun 2020, 19:03

if the game implements something to break pixelsearch after 5 minutes, then it would break imagesearch as well

that said, i cant say i believe thats what happens. it sounds like total nonsense, really. theres probably some other errors in ur code causing it to fail(faulty coordmode usage, miscalculated coords, logic/syntax errors etc)

michelxd15
Posts: 132
Joined: 08 Aug 2019, 02:02

Re: image search help

Post by michelxd15 » 04 Jun 2020, 21:15

@swagfag
I understand and generally when a game uses something that prevents it, is there any way to do it?
I've seen a person who managed to create with AHK a tool to do this and more.
would you know which system you may have used? I appreciate your attention and education!


Below is the github link for the program that does it all, but it is paid and I would like to create something for free
https://github.com/Gilbertobal/OldBot

I was unable to analyze the system he used for creation, his system is also functional only in widows 10 if I'm not mistaken

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

Re: image search help

Post by swagfag » 05 Jun 2020, 11:16

I understand and generally when a game uses something that prevents it, is there any way to do it?
I've seen a person who managed to create with AHK a tool to do this and more.
would you know which system you may have used?
ill level with u. i have 0 clue what ure talking about
program that does it all
looks like plain ImageSearch/FindText(), which relies on gdip, which itself relies on gdi, which means if what u claim is true(that it works), then PixelSearch/GetColor would also work

Post Reply

Return to “Gaming Help (v1)”