help with get color and if

Ask gaming related questions (AHK v1.1 and older)
Qplshakyz
Posts: 35
Joined: 13 Apr 2021, 12:07

help with get color and if

14 Apr 2021, 07:10

So what my script basicly should do is start the script and keeps running until it finds the Specific color in a x,y Coordinate and then start the loop again
it seems like that the loop is running but its not searching for the specific color im curious is Pixelget Color even the Right Code or is PixelSearch Better

Code: Select all

f1::

loop{
IfWinExist, Remote


	{
	Send,{Enter down}
	Sleep, 100
	Send, {Enter up}
	Sleep, 100
	Send,{Enter down}
	Sleep, 100
	Send, {Enter up}
	Sleep, 100
	Send,{Enter down}
	Sleep, 135
	Send, {Enter up}
	
		PixelgetColor, color, 941, 291,
	if color = 0x631B1C
	
		{
			Send, {Down 1}
		}
	}
	
	}

	
	
	
}
Return

F2::
reload
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: help with get color and if

14 Apr 2021, 07:20

Your script seems to match your description. What color is found? You can display it. Is your target window active when the search occurs?
Qplshakyz
Posts: 35
Joined: 13 Apr 2021, 12:07

Re: help with get color and if

14 Apr 2021, 07:32

Yes the Target Window is on. The loop was running and the Color that it was looking for passed by. It shoul stop at this point Send Arrow comman Down and then Repeats the Cycle.

The x,y Coordinates have to be Changed for Sure but Besides that everything should pretty much the Same
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: help with get color and if

14 Apr 2021, 07:37

Use a MsgBox to show you the color. What is it? Have you specified a blue-green-red color format?

Issue a MouseMove to those same coordinates, to help you verify that the coordinates are the right ones.

If you are saying that the coordinates are the wrong ones, then why would the script work?
Qplshakyz
Posts: 35
Joined: 13 Apr 2021, 12:07

Re: help with get color and if

14 Apr 2021, 07:47

I got a Program thats shows me the x,y Coordinate and the Color. I mean Like when i start the Script the x,y Coordinates are correct since its at the Position where i want it to look for but When the Script found the Color it should send the Command down by Sending the Comman down i would be at a different x,y Coordinate so like this:

Code: Select all

Sleep, 135
	Send, {Enter up}

PixelgetColor, color, 941, 291,
	if color = 0x631B1C
	
		{
			Send, {Down 1}   , After this the loop starts again
		
	
	}
	{
	Send,{Enter down}
	Sleep, 100
	Send, {Enter up}
	Sleep, 100
	Send,{Enter down}
	Sleep, 100
	Send, {Enter up}
	Sleep, 100
	Send,{Enter down}
	Sleep, 135
	Send, {Enter up}

PixelgetColor, color, 941, 421, <-- different Coordinate
	if color = 0x631B1C
	
		{
			Send, {Down 1}   , After this the loop starts again
		
	
	}
Last edited by gregster on 14 Apr 2021, 07:49, edited 1 time in total.
Reason: [code] tags added. Please use them yourself, next time. Thank you!
Qplshakyz
Posts: 35
Joined: 13 Apr 2021, 12:07

Re: help with get color and if

14 Apr 2021, 07:50

Is it possible to put more Variable in Color inside so lets say 0x631B1C +1? Or even more Color Codes

like

0x631B1C, 0x601815 to widen the Range
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: help with get color and if

14 Apr 2021, 07:54

To skip the remaining commands in the current loop iteration, use Continue.

A trick for variation is to use PixelSearch targeting a range of one pixel. You can then include the variation parameter.
Qplshakyz
Posts: 35
Joined: 13 Apr 2021, 12:07

Re: help with get color and if

14 Apr 2021, 09:56

https://ibb.co/BtKhN8m

The White Marked Area is the Where PixelSearch should look for

Top left Corner is 740,180

Bottom Right Corner is 743,300

The Right Side of the Picture shows when Color is "normal"

I Got a Wide Range of Red Color Codes like: 0x5D1311, 0x711E1F, 0x6A1A19, 0x772526, 0x350403, 0x772526, 0x661C1C, 0x732320, 0x6E1E1B,
0x7C2928, 0x70201F, 0x691B1A, 0x671517, 0x55120E, 0x3B0401, 0x4F1310, 0x581412, 0x581513, 0x5C1010


At the moment the Script part looks like this just to see if it would find the Color "Red"

Code: Select all

f1::

PixelSearch, px, py, 740, 178, 743, 300, 0x5D1311, 40, Fast

if ErrorLevel
	Msgbox, No
else
    Send, {Down 1}
I Tested it with the Left and Right side of the Picture and it couldnt find the Color on the Left
Qplshakyz
Posts: 35
Joined: 13 Apr 2021, 12:07

Re: help with get color and if

14 Apr 2021, 10:04

I tested it in the targeted window the script
Qplshakyz
Posts: 35
Joined: 13 Apr 2021, 12:07

Re: help with get color and if

14 Apr 2021, 10:12

Could it be possible that the Range is to low or the Area where it has to Search is not define enough?
When i put the Range to 70 it does something but also skips the wrong Picture also sometimes
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: help with get color and if

14 Apr 2021, 10:16

The default color format is blue-green-red, and this might differ from how you identified the color.
By default, coordinates are relative to the active window. Window Spy can show you the coordinates.
Start with a separate solid-color image, with no variation, so that you can test it and understand how the search works.
Qplshakyz
Posts: 35
Joined: 13 Apr 2021, 12:07

Re: help with get color and if

14 Apr 2021, 13:37

So Basically most of the stuff i understood now but i want to stop the loop when the Pixel was found where do i have to Implement the If else Formular
like Loop hits enter and if the Pixel was found Send {Down 1} else start loop again

Code: Select all

settitlematchmode,2
Coordmode, Pixel, Window
SetBatchLines, -1
#NoEnv
SetKeyDelay, 0, 100


F1::
loop{
IfWinExist, Remote



                {
                  Send,{Enter down}
                  Sleep, 100
                  Send,{Enter up}
                  sleep 100
                  send,{Enter down}
                  sleep,100
                  send,{Enter up}
                  Sleep 5000
                }
                    {
                       PixelSearch, px, py, 988, 250, 990, 252, 0x320B06, 50, Fast RGB :::::: dont know if this line is in the correct placement should find the pixel after it did the command above

                          if ErrorLevel
                            {
                            return
                            }
                            else
                            {
                            break
                            }
                    }
                
             
              
                 
     }


Return

F2::
reload
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: help with get color and if

14 Apr 2021, 15:25

Maybe something like the following.

Code: Select all

F1::
SetKeyDelay, 100, 100
Loop {
 Sleep, 250
 SoundBeep, 1500
 If WinExist("Remote")
 {
  Send {Enter 2}
  Sleep, 4900
 }
 PixelSearch,,, 988, 250, 990, 252, 0x320B06, 50, Fast RGB
} Until !ErrorLevel
Send {Down}
Return
Qplshakyz
Posts: 35
Joined: 13 Apr 2021, 12:07

Re: help with get color and if

14 Apr 2021, 15:55

so the Pixelsearch will Activate after the Column with Enter was Proced and when the Pixel was not found it will return to the loop?

so i dont need a if or else command after pixelsearch until is enough?

Im so thankful that you help me so much btw Great Support :bravo:
User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: help with get color and if

14 Apr 2021, 16:11

Correct. In this case, the Until statement will handle the check with each iteration. You can test it to see if it works.

Send will send to whichever window is active at the time.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Google [Bot], jameswrightesq and 158 guests