Code: Select all
global agilityPixelPattern := "D:\agility_pixel_pattern.png"
global chatPixelPattern := "D:\chat_pixel_pattern.png"
global consolePixelPattern := "D:\console_pixel_pattern.png"
; Calculate the coordinates for the bottom half, top half, left half, and right half of the screen
bottomHalfHeight := A_ScreenHeight / 2
topHalfHeight := bottomHalfHeight
leftHalfWidth := A_ScreenWidth / 2
rightHalfWidth := leftHalfWidth
; Initialize a variable to store permission status
conditionsMet := AreConditionsMet()
; Set a timer to check permission every 50ms
SetTimer, CheckPermission, 50
Return
CheckPermission:
; Check for permission and update the variable
conditionsMet := AreConditionsMet()
Return
AreConditionsMet() {
; Check for specific pixel patterns on the screen
return !ImageSearchSuccess(chatPixelPattern) && !ImageSearchSuccess(consolePixelPattern, "EntireScreen") && ImageSearchSuccess(agilityPixelPattern)
}
ImageSearchSuccess(pattern, searchRegion := "BottomHalf") {
if (searchRegion = "BottomHalf") {
ImageSearch, foundX, foundY, 0, %bottomHalfHeight%, A_ScreenWidth, A_ScreenHeight, %pattern%
} else if (searchRegion = "EntireScreen") {
ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %pattern%
}
return !ErrorLevel
}
#If WinActive("ahk_exe game.exe") && (conditionsMet)
*~$q::
Send, q{LButton}q{LButton}q{LButton}
Return