#include <WinAPIEx.au3>;Yashied, http://autoit-script.ru/index.php/topic,47.0.html
;#include <Array.au3>
;координаты смотрел на разрешении 1024x768, у Вас могут быть другие
Dim $aNum[13][3] = [[12],[4, 296, 1],[66, 296, 2],[128, 296, 3], _
[4, 326, 4],[66, 326, 5],[128, 326, 6], _
[4, 356, 7],[66, 356, 8],[128, 356, 9], _
[4, 386, '*'],[66, 386, 0],[128, 386, '#']]
$sEdit = '[NAME:tbDialNumber]'
$j = 0
If Not WinExists('GWTalk') Then
Run(@ProgramFilesDir & '\SKyPRO\GWTalk\GWTalk.exe')
EndIf
$hWin = WinWait('GWTalk', '', 20)
If Not $hWin Then
MsgBox(16, 'Error', 'Нет окна')
Exit
EndIf
$aData = _WinAPI_EnumChildWindows($hWin)
If @error Then
MsgBox(16, 'Error', 'Error')
Exit
EndIf
Dim $aButton[$aData[0][0] + 1][2]
For $i = 1 To $aData[0][0]
$aTemp = ControlGetPos($hWin, '', $aData[$i][0])
If Not @error Then
If $aTemp[2] == 60 And $aTemp[3] == 28 Then
$j += 1
For $q = 1 To $aNum[0][0]
If $aTemp[0] == $aNum[$q][0] And $aTemp[1] == $aNum[$q][1] Then
$aButton[$j][0] = $aNum[$q][2]
ExitLoop
EndIf
Next
$aButton[$j][1] = $aData[$i][0]
ElseIf $aTemp[2] == 184 And $aTemp[3] == 21 Then
$j += 1
$aButton[$j][0] = 'Clear'
$aButton[$j][1] = $aData[$i][0]
EndIf
EndIf
Next
If $j <> 13 Then
MsgBox(16, 'Error', 'Error')
Exit
EndIf
$aData = 0
$aTemp = 0
ReDim $aButton[$j + 1][2]
$aButton[0][0] = $j
;_ArrayDisplay($aButton, 'Buttons')
For $i = 1 To 5
For $j = 1 To $aButton[0][0]
If $aButton[$j][0] == 'Clear' Then
If _ActivateWin($hWin) Then
ControlClick($hWin, '', $aButton[$j][1])
Sleep(100)
ConsoleWrite(ControlGetText($hWin, '', $sEdit) & @LF)
ExitLoop
Else
MsgBox(16, 'Error', 'Error')
Exit
EndIf
EndIf
Next
$sNum_Random = ''
For $j = 1 To 10
$sNum_Random &= Random(0, 9, 1)
Next
If Not Mod($i, 3) Then $sNum_Random &= '#'
If Not Mod($i, 4) Then $sNum_Random &= '*'
MsgBox(64, $i & ' (5)', 'Будем набирать: ' & $sNum_Random)
$aNum_Random = StringSplit($sNum_Random, '')
For $j = 1 To $aNum_Random[0]
For $q = 1 To $aButton[0][0]
If $aNum_Random[$j] == $aButton[$q][0] Then
If _ActivateWin($hWin) Then
ControlClick($hWin, '', $aButton[$q][1])
Sleep(100)
ConsoleWrite(ControlGetText($hWin, '', $sEdit) & @LF)
ExitLoop
Else
MsgBox(16, 'Error', 'Error')
Exit
EndIf
EndIf
Next
Next
MsgBox(64, $i & ' (5)', 'Должны набрать:' & @TAB & $sNum_Random & @LF & 'Набрали номер:' & _
@TAB & ControlGetText($hWin, '', $sEdit))
Next
Func _ActivateWin($h_Wnd)
If Not WinExists($h_Wnd) Then Return False
If Not WinActive($h_Wnd) Then WinActivate($h_Wnd)
Return WinWaitActive($h_Wnd, '', 5) = $h_Wnd
EndFunc ;==>_ActivateWin