#include <Array.au3>
Opt('PixelCoordMode', 2)
Opt('WinTitleMatchMode', 2)
HotKeySet('{Esc}', '_Exit')
Dim $aResult[1001][2] = [[1000]]
$iCount = 0
$iColor = 0x000000
$iX = 0
$iY = 0
$iVariation = 10 ;чем больше, тем больше найдет
$sTitle = 'AutoIt v3 Window Info' ;заголовок Вашего окна
$hWin = WinWait($sTitle, '', 3)
If Not $hWin Then
MsgBox(16, 'Error', 'Нет такого окна')
Exit
EndIf
If Not WinActive($hWin) Then
WinActivate($hWin)
WinWaitActive($hWin)
EndIf
$aPos = WinGetPos($hWin)
$aMax = WinGetClientSize($hWin)
If $aPos[0] < 0 Or $aPos[1] < 0 Or ($aPos[0] + $aPos[2]) > @DesktopWidth Or _
($aPos[1] + $aPos[3]) > @DesktopHeight Then
WinMove($hWin, '', 0, 0)
$aPos = WinGetPos($hWin)
$aMax = WinGetClientSize($hWin)
EndIf
$iX_k = $aPos[0] + ($aPos[2] - $aMax[0]) / 2
$iY_k = $aPos[1] + ($aPos[3] - $aMax[1]) - ($aPos[2] - $aMax[0]) / 2
$iX_max = $aMax[0]
$iY_max = $aMax[1]
ToolTip('Ищем здесь', 0, 0)
MouseMove($iX_k, $iY_k)
Sleep(1000)
MouseMove($iX_k, $iY_k + $aMax[1])
Sleep(1000)
MouseMove($iX_k + $aMax[0], $iY_k + $aMax[1])
Sleep(1000)
MouseMove($iX_k + $aMax[0], $iY_k)
Sleep(1000)
MouseMove($iX_k, $iY_k)
ToolTip('', 0, 0)
$iStart = TimerInit()
While 1
If Not WinExists($hWin) Then ExitLoop
If Not WinActive($hWin) Then
WinActivate($hWin)
WinWaitActive($hWin)
EndIf
PixelSearch($iX, $iY, $iX, $iY, $iColor, $iVariation, 1, $hWin)
If Not @error Then
$iCount += 1
ToolTip($iCount & @LF & $iY & 'x' & $iY, 0, 0)
If $iCount = $aResult[0][0] Then
$aResult[0][0] += 1000
ReDim $aResult[$aResult[0][0] + 1][2]
EndIf
$aResult[$iCount][0] = $iX
$aResult[$iCount][1] = $iY
MouseMove($iX + $iX_k, $iY + $iY_k, 0)
EndIf
$iX += 1
If $iX = $iX_max Then
$iX = 0
$iY += 1
If $iY = $iY_max Then ExitLoop
EndIf
WEnd
ToolTip('', 0, 0)
$sTime = StringFormat('%.2f sec', TimerDiff($iStart) / 1000)
If $iCount Then
ReDim $aResult[$iCount + 1][2]
$aResult[0][0] = $iCount
$aResult[0][1] = $aMax[0] & 'x' & $aMax[1]
;В массиве координаты относительно клиентской части окна
_ArrayDisplay($aResult, $sTime)
Else
MsgBox(16, 'Error', 'Нет такого цвета' & @LF & $sTime)
EndIf
Func _Exit()
Exit
EndFunc ;==>_Exit