#AHK : WaitForImage # WaitForImage(ByRef pic, ByRef windowRef, ByRef timeout) { coordmode, pixel, screen WinGetPos, winX, winY, winWidth, winHeight, %windowRef% waitVal = 100 count = 0 maxIter := timeout / waitVal while count < maxIter { IfWinNotActive, %windowRef% WinActivate, %windowRef% ImageSearch, imageX, imageY, winX, winY, winX+winWidth, winY+winHeight, %pic% if not ErrorLevel ; Found ! { coordmode, pixel, Relative return true } Sleep waitVal count += 1 } coordmode, pixel, Relative return false }