Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
CoordMode, Mouse, Screen
Input, UserInput, L1, ]
#Persistent
SetTimer, CheckButtonPosition, 4000 ; Check every second
return
; Checks to see if we see the button then runs all 3 error levels
CheckButtonPosition:
ImageSearch, TopLeftXOfImage, TopLeftYOfImage, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Users\jack\Downloads\festival_icon.jpg
if ErrorLevel = 1 ; If the image is not found
{
; Scroll down to the next page
Send, {WheelDown}
Sleep, 1000
}
if ErrorLevel = 0 ; If the image is found
{
; Move the mouse to the button and click
Click, %TopLeftXOfImage%, %TopLeftYOfImage%
Pause
}
if ErrorLevel = 2 ; If there is an error that prevents the search
{
MsgBox, not_working
}
return
Code: Select all
CoordMode, Pixel, Screen
Input, UserInput, L1, ]
PixelGetColor, colour, 219, 241
if (colour == 00FFA4)
{
Click, 219, 241
}
else
{
MsgBox, nope
}
[Mod action: Moved topic from AHK v2 help to v1 help, based on posted code. ]