Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <MsgBoxConstants.au3>
- Global $hWnd = 0
- Global $userIds = 0
- Func DisplayError($cond,$text,$cap="error")
- If $cond == True Then
- MsgBox($MB_SYSTEMMODAL, $cap, $text)
- Exit 0
- EndIf
- EndFunc
- Func Init()
- Local $res
- $res = WinWait("[Class:Tmf]","",5)
- DisplayError($res == 0,"Grabber is not running")
- $hWnd = WinGetHandle("[Class:Tmf]")
- DisplayError(@error,"Cannot get main window handle")
- $userIds = FileReadToArray("X:\\grabber.txt")
- EndFunc
- Func DownloadUser($userId)
- Local $res
- Local $hGrid
- Local $hTextEdit
- Local $hMainMenu
- Local $hError
- Local $pagePos
- Local $windowPos
- Local $getListTimeout = 120
- Local $downloadTimeout = 300
- WinActivate($hWnd)
- Sleep(500)
- ; Жмем "New list"
- $res = ControlClick($hWnd,"","[CLASS:TcxButton;TEXT:New list]")
- DisplayError($res == 0,"Cannot click New List")
- Sleep(7000)
- ; Задаём UserId
- $hGrid = ControlGetHandle($hWnd,"[CLASS:TcxVerticalGrid:INSTANCE:3]","")
- DisplayError($hGrid == 0,"Cannot get grid handle")
- $res = ControlClick($hWnd,"",$hGrid,"left",1,300,100)
- DisplayError($res == 0,"Cannot click grid")
- $hTextEdit = ControlGetHandle($hWnd,"[CLASS:TcxCustomInnerTextEdit:INSTANCE:1]","")
- DisplayError($hTextEdit == 0,"Cannot get text Edit Handle")
- ;$res = ControlSetText($hwnd,"",$hTextEdit,"1000")
- $res = ControlSend($hwnd,"",$hTextEdit,$userId & @CR)
- DisplayError($res == 0,"Cannot set user")
- Sleep(1000)
- ; Жмём Finish
- $res = ControlClick($hWnd,"","[CLASS:TcxButton;TEXT:Finish]")
- DisplayError($res == 0,"Cannot click finish")
- ; Ждем пока лист прибудет
- Sleep($getListTimeout*1000)
- #cs
- ; почемуто не получается нажать Start To Download Pictures по хендлу контрола
- $hMainMenu = ControlGetHandle($hWnd,"[CLASS:TdxBarControl]","")
- DisplayError($hMainMenu == 0,"Cannot get main menu handle")
- ;$res = ControlClick($hWnd,"",$hMainMenu,"right",1,15,15)
- ;DisplayError($res == 0,"Cannot click start downloading pictures")
- #ce
- ; жмём Start To Download Pictures
- WinActivate($hWnd)
- Sleep(500)
- $windowPos = WinGetPos($hWnd)
- MouseClick("left",$windowPos[0]+59,$windowPos[1]+25+13)
- #cs
- ; закрывалка тоже не работает
- Local $hPage = ControlGetHandle($hWnd,"[CLASS:TcxTabSheet;INSTANCE:2]","")
- DisplayError($hPage == 0,"Cannot get page handle")
- $res = ControlClick($hWnd,"",$hPage,"left",70,12)
- DisplayError($res == 0,"Cannot close page")
- ConsoleWrite($hPage)
- #ce
- ; Пытаемся закрыть лист, если всплывает ошибка (ещё качается)
- ; закрываем сообщение об ошибке и спим ещё таймаут
- ; если ошибка не всплывает значит всё скачалось, можно выходить из цикла и функции
- Do
- Sleep($downloadTimeout*1000)
- WinActivate($hWnd)
- Sleep(500)
- $windowPos = WinGetPos($hWnd)
- $pagePos = ControlGetPos($hWnd,"","[CLASS:TcxPageControl]")
- MouseClick("left",$windowPos[0]+$pagePos[0]+73,$windowPos[1]+$pagePos[1]+12+25)
- Sleep(500)
- $hError = WinGetHandle("[CLASS:TMessageForm]")
- If $hError <> 0 Then
- $res = ControlClick($hError,"","[CLASS:TButton]")
- Else
- ExitLoop
- EndIf
- Until False
- EndFunc
- ; Main
- Init()
- Local $userId
- For $userId in $userIds
- DownloadUser($userId)
- Next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement