1

i wanted to afk or have some break while leveling my character,the green box are the monster yea i messed around inside game files and edited it with photoshop lol,

my script is doing perfectly fine and attacking monster, but how can I make pixelsearch/attack only in the middle screen? to avoid my character from deaths. It doesn't work i dont know why. can you suggest me what's wrong? enter image description here

    CoordMode, Pixel, Relative
    SetMouseDelay, -1

    Home:: press home to start

   ;assuming to search in a reactangle area 200x200px

    leftBound   := A_ScreenWidth  / 2 - 100
    rightBound  := A_ScreenWidth  / 2 + 100
    topBound    := A_ScreenHeight / 2 - 100
    bottomBound := A_ScreenHeight / 2 + 100

Loop {

PixelSearch, X, Y, leftBound, topBound, rightBound, bottomBound, 0x00FF00, 0, fast
            if(ErrorLevel=0) 
            {
               MouseClick, left, %X%, %Y%


            }
            else {

                Send {F9}
                sleep, 50


            }
        }
    return

    PgUp::Pause
    End::ExitApp

1 Answers1

2

You need to put the variables into percent signs %:

PixelSearch, X, Y, %leftBound%, %topBound%, %rightBound%, %bottomBound%, 0x00FF00, 0, fast

Also see the documentation for details:

For X1,Y1, it says:

The X and Y coordinates of the upper left corner of the rectangle to search

By "coordinates", obviously a number is described. This means, that in this case, you need to state a value and not variable's name. The values are stored inside the variables, so use the percent signs to access the variable content.

phil294
  • 10,038
  • 8
  • 65
  • 98