Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- #SingleInstance Force
- searchQuadrantA() {
- global
- sleep, 250
- ;This should be a function so i can loop until it ends
- MouseMove, x1%a%, y1%a% ;The search square x1, y1
- sleep, 500
- MouseMove, x2%a%, y2%a% ;The search square x2, y2
- sleep, 500
- PixelSearch, Fx%a%, Fy%a%, x1%a%, y1%a%, x2%a%, y2%a%, 0xFFFFFF, 1, Fast
- If (ErrorLevel == 1)
- Return
- If (ErrorLevel == 0) {
- sleep, 1000
- MouseMove, Fx%a%, Fy%a%
- ;Here is where the function should be, for what you want to happen in the pixel or image
- ControllerA%a% := 1 ;Activate controllers that check if quadrants exist or if pixel is in one of the edge of the screen.
- ControllerC%a% := 1
- ;If Fx1 is the start and the area (10), then it means it we have no A quadrant only b and c
- If (Fx%a% <= x1%a%)
- ControllerA%a% := 0
- If (Fx%a% >= x2%a%)
- ControllerC%a% := 0
- MsgBox % "SearchQuadrant A `n"
- . "ControllerA%a% " ControllerA%a% "`n"
- . "ControllerC%a% " ControllerC%a% "`n"
- . "Fx " Fx%a% "`n"
- . "Fy " Fy%a% "`n"
- . "x1 " x1%a% "`n"
- . "y1 " y1%a% "`n"
- . "x2 " x2%a% "`n"
- . "y2 " y2%a% "`n"
- . "Number " a "`n"
- sleep, 500
- ;#################### SEARCH A.A. QUADRANT A FROM QUADRANT A #####################
- If (ControllerA%a% == 1) {
- PreFx := Fx%a% ;save "previous" ( or current coordinates into variables so i can operate with the new ones)
- PreFy := Fy%a%
- Prex1 := x1%a%
- Prey1 := y1%a%
- Prex2 := x2%a%
- Prey2 := y2%a%
- a++ ;increases the number of a so that we can record the next coordinates for the next search
- MsgBox % "after a ++ a is now " a "`n" ;lets the use know a new search will be performed
- x1%a% := Prex1 ;x 190
- y1%a% := PreFy + 2 ;1 below ; if the reading of pixels is from left to right
- x2%a% := PreFx
- y2%a% := Prey2
- MsgBox % "SearchQuadrantA from another Quadrant A`n" ;This is to let the user know a search will be conducted on a quadrant A coming from a quadrant A
- searchQuadrantA()
- a-- ;After the search is done, we go to the previous values, so to perform a search on the C quadrant now.
- MsgBox % "after a-- a is now " a "`n"
- }
- ;#################### SEARCH A.C. QUADRANT A FROM QUADRANT C #####################
- If (ControllerC%a% == 1) {
- PreFx := Fx%a% ;save previous (current coordinates into variables so i can operate with the new ones)
- PreFy := Fy%a%
- Prex1 := x1%a%
- Prey1 := y1%a%
- Prex2 := x2%a%
- Prey2 := y2%a%
- a++
- MsgBox % "after a++ a is now " a "`n"
- x1%a% := PreFx + 2 ;its to the right of last Found pixel
- y1%a% := PreFy ;its on the same line
- x2%a% := Prex2 ;its to the right
- y2%a% := Prey2
- MsgBox % "SearchQuadrantC from A`n"
- searchQuadrantC()
- a--
- MsgBox % "after a -- a is now " a "`n"
- }
- }
- }
- searchQuadrantC() {
- global
- sleep, 500
- MouseMove, x1%a%, y1%a%
- sleep, 500
- MouseMove, x2%a%, y2%a%
- sleep, 500
- PixelSearch, Fx%a%, Fy%a%, x1%a%, y1%a%, x2%a%, y2%a%, 0xFFFFFF, 1, Fast
- If (ErrorLevel == 1)
- Return
- If (ErrorLevel == 0) {
- sleep, 1000
- MouseMove, Fx%a%, Fy%a%
- MsgBox % "Found a Pixel in C"
- ControllerA%a% := 1 ;Activate controllers that check for quandrant, no need you can simply do ++, but anyways
- ControllerC%a% := 1
- If (Fx%a% <= x1%a% )
- ControllerA%a% := 0 ;If Fx1 is the start and the area (10), then it means it we have no A quadrant only b and c
- ;#################### SEARCH C.A. QUADRANT C FROM QUADRANT A #####################
- If (ControllerA%a% == 1) {
- PreFx := Fx%a% ;save previous (current coordinates into variables so i can operate with the new ones)
- PreFy := Fy%a%
- Prex1 := x1%a%
- Prey1 := y1%a%
- Prex2 := x2%a%
- Prey2 := y2%a%
- a++
- MsgBox % "after a ++ a is now " a "`n"
- x1%a% := Prex1
- y1%a% := PreFy + 2
- x2%a% := PreFx
- y2%a% := Prey2
- MsgBox % "SearchQuadrant A from Quadrant C`n"
- searchQuadrantA()
- a--
- MsgBox % "after a-- a is now " a "`n"
- }
- ;And here you should make a loop to check Quadrant A that will break at Ay2 and continue to the next quadrants
- ;#################### SEARCH C.C. QUADRANT C FROM QUADRANT C #####################
- If (ControllerC%c% == 1) {
- PreFx := Fx%a% ;save previous (current coordinates into variables so i can operate with the new ones)
- PreFy := Fy%a%
- Prex1 := x1%a%
- Prey1 := y1%a%
- Prex2 := x2%a%
- Prey2 := y2%a%
- a++
- MsgBox % "after a++ a is now " a "`n"
- x1%a% := PreFx + 1 ;its to the right
- y1%a% := PreFy + 1 ;its on the same line
- x2%a% := Prex2 ;its to the right
- y2%a% := Prey2
- MsgBox % "SearchQuadrant C from Quadrant C`n"
- searchQuadrantC()
- a--
- MsgBox % "after a-- a is now " a "`n"
- }
- a--
- MsgBox % "after a -- a is now " a "`n"
- }
- }
- ;########################################################
- ;################### ACTUAL START ######################
- ;########################################################
- ;«::
- f1::
- CoordMode, Mouse, screen
- CoordMode, Pixel, screen
- Cropx1 := 100
- Cropy1 := 100
- Area := 50
- x11 := 0 + Cropx1
- y11 := 0 + Cropy1
- a := 0
- ;725
- x21 := A_ScreenWidth - Cropx1
- y21 := A_ScreenHeight - 175 - Cropy1 ;counting with the game gui ;725 - 900 = 175 + 100 = 275
- ;################################################################
- ;##################### FIRST PIXEL SEARCH #######################
- ;################################################################
- a++
- PixelSearch, Fx%a%, Fy%a%, x1%a%, y1%a%, x2%a%, y2%a%, 0xFFFFFF, 1, Fast ;Fx1 f stands for found is the main and first pixel found
- If (ErrorLevel == 0) {
- sleep, 250
- MouseMove Fx%a%, Fy%a% ; pixel detected, move
- ControllerA%a% := 1 ;Activate controllers that check for quandrant
- ControllerC%a% := 1
- If (Fx%a% <= x1%a% + 1)
- ControllerA := 0
- If (Fx%a% >= x2%a% - 1)
- ControllerC%a% := 0
- MsgBox % "SearchQuadrant A `n"
- . "ControllerA%a% " ControllerA%a% "`n"
- . "ControllerC%a% " ControllerC%a% "`n"
- . "Fx " Fx%a% "`n"
- . "Fy " Fy%a% "`n"
- . "x1 " x1%a% "`n"
- . "y1 " y1%a% "`n"
- . "x2 " x2%a% "`n"
- . "y2 " y2%a% "`n"
- . "a " a "`n"
- sleep, 500
- If (ControllerA%a% == 1) {
- PreFx := Fx%a% ;save "previous" (current coordinates into variables so i can operate with the new ones)
- PreFy := Fy%a%
- Prex1 := x1%a%
- Prey1 := y1%a%
- Prex2 := x2%a%
- Prey2 := y2%a%
- a++
- x1%a% := Prex1
- y1%a% := PreFy + 1
- x2%a% := PreFx
- y2%a% := Prey2
- searchQuadrantA()
- }
- If (ControllerC%a% == 1) {
- PreFx := Fx%a% ;save previous (current coordinates into variables so i can operate with the new ones)
- PreFy := Fy%a%
- Prex1 := x1%a%
- Prey1 := y1%a%
- Prex2 := x2%a%
- Prey2 := y2%a%
- a++
- x1%a% := PreFx
- y1%a% := PreFy
- x2%a% := Prex2
- y2%a% := Prey2
- searchQuadrantC()
- a--
- }
- }
- return
- +r::
- reload
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement