#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <Timers.au3>
Global $Pause = True
Global $txte
Global $oElementexit, $oParent, $iPercent, $contextmenu, $button, $buttoncontext, $buttonitem
Global $fWork=0
Global $UIA_AnswerEventProc = DllCallbackRegister("__UIA_AnswerEventProc", "none", "ptr;dword;hwnd;long;long;dword;dword")
Global $UIA_AnswerEventHook = _WinAPI_SetWinEventHook($EVENT_SYSTEM_ALERT, $EVENT_SYSTEM_ALERT, DllCallbackGetPtr($UIA_AnswerEventProc))
Local $x1 = 0, $y1 = 0
Local $x1e = 0, $y1e = 0
Local $x11 = 0, $y11 = 0
Local $x12 = 0, $y12 = 0
Local $x22 = 0, $y22 = 0
Local $x23 = 0, $y23 = 0
Local $x33 = 0, $y33 = 0
Local $x34 = 0, $y34 = 0
Local $xw = 0, $yw = 0
Local $v = 0
HotKeySet('{ESC}', '_Pro_Exit')
HotKeySet("{F10}","Stop")
Opt("GUIOnEventMode", 1) ; Включает режим OnEvent
$mainwindow = GUICreate("Какой-то текст", 300, 400)
GUICtrlSetBkColor(-1, 0xD2D2D2)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Рабочее окно", 30, 10)
$okbutton = GUICtrlCreateButton("Пуск", 55, 320, 80)
GUICtrlSetOnEvent($okbutton, "_WorkScript")
GUISetState(@SW_SHOW)
$eXbutton = GUICtrlCreateButton("Выход", 210, 350, 80)
GUICtrlSetOnEvent($eXbutton, "_Pro_Exit")
GUISetState(@SW_SHOW)
$nButtonPause = GUICtrlCreateButton("Пауза", 105, 350, 80)
GUICtrlSetOnEvent($nButtonPause, "_Pausebtm")
GUISetState(@SW_SHOW)
$Stopbutton = GUICtrlCreateButton("Стоп", 20, 350,80)
GUICtrlSetOnEvent($Stopbutton, "_Pro_Exit")
GUISetState(@SW_SHOW)
Local $hHighlight_Capture = GUICreate('', 200, 300, -1, -1, $WS_POPUPWINDOW, $WS_EX_CONTROLPARENT)
GUISetState(@SW_SHOW)
WinSetOnTop($hHighlight_Capture, '', 1)
GUISetBkColor(0xFF00FF, $hHighlight_Capture)
WinSetTrans($hHighlight_Capture, '', 150)
Local $aPos = WinGetPos($hHighlight_Capture)
WinMove($hHighlight_Capture, '', $aPos[0] + 400, $aPos[1] - 100)
$lLable = GUICtrlCreateLabel('$txte',10, 100, 150, 50)
GUICtrlSetData($lLable, $txte)
;ConsoleWrite("msg = " & $hHighlight_Capture & @CRLF)
$Minst = GUICtrlCreateButton("Пуск", 10, 270, 60)
GUICtrlSetOnEvent($Minst, "_WorkScript")
While 1
Sleep(500) ; Цикл ожидания
WEnd
Func _WorkScript()
if $Pause Then
While 1
if not $Pause Then ;
ExitLoop
EndIf
$begin = TimerInit()
$v = 0
While $v < 1
Opt("WinTitleMatchMode", 2)
$hWnd = WinWait(" - Google Chrome", "", 3)
$oParent = _UIA_GetElementFromHandle($hWnd)
_OwnerFunc()
$dif = TimerDiff($begin)
if $dif > 600000+Random(10000,15000,0) Then
$begin = 0
$dif = 0
_CloseWin ()
$v = $v + 1
EndIf
WEnd
WEnd
EndIf
EndFunc
Func _OwnerFunc()
_SearchElement ()
if $oElementexit = 0 Then ;Если элемент пропала заходим в цикл
_SearchElement ()
sleep (100+Random(100,1500,0))
if $oElement1 <> 0 Then ;если элемент 1 появилась заходим в цикл
_UIA_ElementScrollIntoView($oElement1)
$oElement1x = _UIA_ElementGetBoundingRectangle($oElement1) ;получаем область координат нахождения элемента 1
$x1 = _UIA_ElementGetBoundingRectangle($oElement1) ;получаем координату "х" искомого элемента
$y1 = _UIA_ElementGetBoundingRectangle($oElement1) ;получаем координату "у" искомого элемента
Sleep (1000+Random(100,1500,0))
MouseMove($x1[0]+Random(20,80,0),$y1[1]+Random(5,7,0),20+Random(0,30,1))
Sleep (1000+Random(100,1500,0))
MouseClick ("left")
Sleep (1000+Random(100,1500,0))
MouseMove(689+Random(0,100,0),280+Random(0,100,0),20+Random(0,30,1))
Sleep (1000+Random(100,1500,0))
MouseClick ("left")
Sleep (1000+Random(100,1500,0))
MouseWheel("down",2)
Sleep (5000+Random(100,1000,0))
For $c = 0 To 6
MouseWheel("down",2)
Sleep (5000+Random(100,1000,0))
Next
_SearchElement ()
$oElement2x = _UIA_ElementGetBoundingRectangle($oElement2) ;получаем область координат нахождения элемента 2
$x11 = _UIA_ElementGetBoundingRectangle($oElement2) ;получаем координату "х" искомого элемента
$y11 = _UIA_ElementGetBoundingRectangle($oElement2) ;получаем координату "у" искомого элемента
MouseMove($x11[0]+Random(10,30,0),$y11[1]+Random(5,15,0),20+Random(0,30,1))
Sleep (1000+Random(500,2500,0))
MouseClick ("left")
Sleep (3000+Random(1000,3000,0))
EndIf
_SearchElement ()
if $oElement3 <> 0 And $oElement1 = 0 And $oElement4 = 0 Then
_UIA_ElementScrollIntoView($oElement3)
Sleep(2000)
$oElement3x = _UIA_ElementGetBoundingRectangle($oElement3) ;получаем область координат нахождения элемента 3
$x12 = _UIA_ElementGetBoundingRectangle($oElement3) ;получаем координату "х" искомого элемента
$y12 = _UIA_ElementGetBoundingRectangle($oElement3) ;получаем координату "у" искомого элемента
MouseMove($x12[0]+Random(10,30,0),$y12[1]+Random(5,15,0),20+Random(0,30,1))
Sleep (800+Random(500,1500,0))
MouseClick ("left")
Sleep (2000+Random(1000,5000,0))
EndIf
_SearchElement ()
if $oElement4 <> 0 Then
_UIA_ElementScrollIntoView($oElement4)
_UIA_ElementSetFocus($oElement4)
$oElement4x = _UIA_ElementGetBoundingRectangle($oElement4) ;получаем область координат нахождения элемента 4
$x22 = _UIA_ElementGetBoundingRectangle($oElement4) ;получаем координату "х" искомого элемента
$y22 = _UIA_ElementGetBoundingRectangle($oElement4) ;получаем координату "у" искомого элемента
MouseMove($x22[0]+Random(0,20,0),$y22[1]+Random(0,8,0),20+Random(0,30,1))
Sleep (1000+Random(3000,10000,0))
MouseClick ("left")
Sleep (500+Random(3000,5000,0))
EndIf
EndIf
EndFunc
;-----------------------------------------------------------------------
; Функция сворачивания окна
Func _CloseWin ()
$hWin = _WinWaitVisible('[CLASS:Chrome_WidgetWin_1]', '', 5)
WinSetState($hWin, '', @SW_MINIMIZE)
Sleep (2000)
EndFunc
Func _WinWaitVisible($sTitle, $sText, $iWait = 0)
Local $iTimer = TimerInit()
Local $hWin = 0, $aList
While 1
$aList = ($sText ? WinList($sTitle, $sText) : WinList($sTitle))
For $i = 1 To UBound($aList) - 1
If BitAND(WinGetState($aList[$i][1]), 2) Then
$hWin = $aList[$i][1]
ExitLoop 2
EndIf
Next
If $iWait And TimerDiff($iTimer) >= ($iWait * 1500) Then
$hWin = -1
ExitLoop
EndIf
Sleep(10)
WEnd
Return (IsHWnd($hWin) ? $hWin : SetError(1, 0, $hWin))
Sleep (500)
EndFunc
; конец функции сворачивания окна
;----------------------------------------------------------------------
Func _SearchElement ()
Global $oElementexit = _UIA_GetControlTypeElement($oParent, "UIA_ButtonControlTypeId", "Значение элемента") ;поиск элемента
$UIA_ConsoleWriteError = 0
Global $oElement1 = _UIA_GetControlTypeElement($oParent, "UIA_ButtonControlTypeId", "Значение элемента 1") ;поиск элемента 1
$UIA_ConsoleWriteError = 0
Global $oElement2 = _UIA_GetControlTypeElement($oParent, "UIA_ButtonControlTypeId", "Значение элемента 2") ;поиск элемента 2
$UIA_ConsoleWriteError = 0
Global $oElement3 = _UIA_GetControlTypeElement($oParent, "UIA_ButtonControlTypeId", "Значение элемента 3") ;поиск элемента 3
$UIA_ConsoleWriteError = 0
Global $oElement4 = _UIA_GetControlTypeElement($oParent, "UIA_ButtonControlTypeId", "Значение элемента 4") ;поиск элемента 4
$UIA_ConsoleWriteError = 0
EndFunc
Func __UIA_AnswerEventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadID, $iEventTime)
If $iEvent = $EVENT_SYSTEM_ALERT And $iObjectID = 1 Then _SendMessage($hWnd, 0x003D, 0, 1) ; $WM_GETOBJECT = 0x003D
EndFunc ;==> __UIA_AnswerEventProc
Func __UIA_Answer_OnAutoItExit()
_WinAPI_UnhookWinEvent($UIA_AnswerEventHook)
DllCallbackFree($UIA_AnswerEventProc)
EndFunc ;==> __UIA_AnswerOnAutoItExit
Func CLOSEClicked()
Exit
EndFunc
Func _Pausebtm()
If not $Pause Then
GUICtrlSetData($nButtonPause, 'Пауза')
$Pause = True
Else
GUICtrlSetData($nButtonPause, 'Продолжить')
$Pause = False
EndIf
EndFunc
Func _Pro_Exit()
Exit
EndFunc