help in code to fix script with image Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Re: help in code to fix script with image

Post by Green Astronaut » 18 Sep 2021, 10:12

Now you can read the text above, my English is not so good but I edited the text above several times to make it as clear as possible.
User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: help in code to fix script with image

Post by mikeyww » 18 Sep 2021, 10:13

I recommend providing a description of exactly what should occur in each of the four possible results.

"When the colors were found" is also vague. Specify whether all colors must be found, or just one of them.
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Re: help in code to fix script with image

Post by Green Astronaut » 18 Sep 2021, 10:18

first search for these colors: [0x8E00BD, 0x8A00B7, 0x8200B0, 0x7D00A9, 0x7A00A3]
at this particular coordinate: 910, 39, 990, 48,

if you don't find these colors:
find this image: Images\utamo.png

if the image is not found, send the "f4" key
however if the image is found send the key "numpadmult"

I think this made the information clearer.
User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: help in code to fix script with image

Post by mikeyww » 18 Sep 2021, 10:22

Actually, it isn't. You have not addressed either of my suggestions.
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Re: help in code to fix script with image

Post by Green Astronaut » 18 Sep 2021, 10:25

sorry for my ignorance, any of the colors can be found to start performing the actions
I'm using a translator and sometimes it's not clear to me what your words are
User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: help in code to fix script with image

Post by mikeyww » 18 Sep 2021, 10:29

I will ask for a third time: what should the script do if one of the colors is found?
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Re: help in code to fix script with image

Post by Green Astronaut » 18 Sep 2021, 10:30

if one of the colors is found:
it goes to image search Imagens\utamo.png
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Re: help in code to fix script with image

Post by Green Astronaut » 18 Sep 2021, 10:31

if the image is not found, send the "f4" key
however if the image is found send the key "numpadmult"
User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: help in code to fix script with image

Post by mikeyww » 18 Sep 2021, 10:32

I am not referring to the image. I am asking about the pixel colors. I think you can simplify the response by referring to the four conditions.

1. Pixel found, image found
2. Pixel found, image not found
3. Pixel not found, image found
4. Pixel not found, image not found

If any of these conditions are not relevant, you can note that, too.
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Re: help in code to fix script with image

Post by Green Astronaut » 18 Sep 2021, 10:34

if one of the colors is found I would just like it to follow the script without any action
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Re: help in code to fix script with image

Post by Green Astronaut » 18 Sep 2021, 10:35

the image search would only be done after confirming that one of the colors was found.
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Re: help in code to fix script with image

Post by Green Astronaut » 18 Sep 2021, 10:37

ok, you can check if the pixel is not found a msgbox will appear warning you, but I don't think it's necessary because I've tested all the colors
User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: help in code to fix script with image

Post by mikeyww » 18 Sep 2021, 10:37

I see. So if the color is found, then there is no action, and if the color is found, then the image search should occur.

I think I will have to let others figure this out. I have no understanding. Sorry.
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Re: help in code to fix script with image

Post by Green Astronaut » 18 Sep 2021, 10:41

you already helped me with a code yesterday when a color is found it just doesn't happen any action just goes to the next checks
I'll paste the code below for you to remember

Code: Select all

Auto_Heal:
PixelSearch,,, 199, 50, 334, 50, 0x707070,, Fast
If !ErrorLevel
 Return
PixelGetColor, GreenColor, 320, 50, RGB
If (GreenColor = 0x00C000)
 Return
PixelGetColor, LightgreenColor, 310, 50, RGB
PixelGetColor, YellowColor    , 270, 50, RGB
PixelGetColor, RedColor       , 235, 50, RGB
If (LightgreenColor != 0x60C060 And YellowColor != 0xC0C000 And RedColor != 0xC03030)
                        ControlSend,, {f5}, Pokemon
Return
Green Astronaut
Posts: 84
Joined: 13 Dec 2020, 08:35

Re: help in code to fix script with image  Topic is solved

Post by Green Astronaut » 18 Sep 2021, 11:04

thank you so much for your time and patience to help me i was selecting the color of the full life instead of the gray color of the empty life, now it worked perfectly. I just have to thank you for your cooperation and patience.
@mikeyww @boiler

Code: Select all

#Persistent
If !FileExist(image := "Imagens\utamo.png")
 MsgBox, 48, Error, File not found.`n`n%image%
Loop {
 WinWaitActive, ahk_class Qt5QWindowOwnDCIcon
 SetTimer, Check, 400
 WinWaitNotActive
 SetTimer, Check, Off
 SoundBeep, 1000
}
Check:
SoundBeep, 1500
CoordMode, Pixel
For each, color in [0x292929, 0x181919, 0x343434, 0x242424, 0x292929, 0x262626, 0x272727]
 PixelSearch, x, y, 910, 39, 990, 48, %color%,, Fast RGB
Until ErrorLevel
If (x = "")
 Return
ImageSearch, x, y, 0, 0, A_ScreenWidth, A_ScreenHeight, %image%
Send % ErrorLevel ? "{F4}" : "{NumpadMult}"
Return
User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: help in code to fix script with image

Post by mikeyww » 18 Sep 2021, 11:43

This script looks incorrect to me, but if it works, then that is all that matters.
Post Reply

Return to “Gaming Help (v1)”