Advertisement
overloop

nekopaw.au3

Apr 24th, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.48 KB | None | 0 0
  1. #include <MsgBoxConstants.au3>
  2.  
  3. Global $hWnd = 0
  4. Global $userIds = 0
  5.  
  6. Func DisplayError($cond,$text,$cap="error")
  7.   If $cond == True Then
  8.     MsgBox($MB_SYSTEMMODAL, $cap, $text)
  9.     Exit 0
  10.   EndIf
  11. EndFunc
  12.  
  13. Func Init()
  14.    Local $res
  15.    $res = WinWait("[Class:Tmf]","",5)
  16.    DisplayError($res == 0,"Grabber is not running")
  17.    $hWnd = WinGetHandle("[Class:Tmf]")
  18.    DisplayError(@error,"Cannot get main window handle")
  19.    $userIds = FileReadToArray("X:\\grabber.txt")
  20. EndFunc
  21.  
  22. Func DownloadUser($userId)
  23.    Local $res
  24.    Local $hGrid
  25.    Local $hTextEdit
  26.    Local $hMainMenu
  27.    Local $hError
  28.    Local $pagePos
  29.    Local $windowPos
  30.  
  31.    Local $getListTimeout = 120
  32.    Local $downloadTimeout = 300
  33.  
  34.    WinActivate($hWnd)
  35.    Sleep(500)
  36.    ; Жмем "New list"
  37.    $res = ControlClick($hWnd,"","[CLASS:TcxButton;TEXT:New list]")
  38.    DisplayError($res == 0,"Cannot click New List")
  39.    Sleep(7000)
  40.    ; Задаём UserId
  41.    $hGrid = ControlGetHandle($hWnd,"[CLASS:TcxVerticalGrid:INSTANCE:3]","")
  42.    DisplayError($hGrid == 0,"Cannot get grid handle")
  43.    $res = ControlClick($hWnd,"",$hGrid,"left",1,300,100)
  44.    DisplayError($res == 0,"Cannot click grid")
  45.    $hTextEdit = ControlGetHandle($hWnd,"[CLASS:TcxCustomInnerTextEdit:INSTANCE:1]","")
  46.    DisplayError($hTextEdit == 0,"Cannot get text Edit Handle")
  47.    ;$res = ControlSetText($hwnd,"",$hTextEdit,"1000")
  48.    $res = ControlSend($hwnd,"",$hTextEdit,$userId & @CR)
  49.    DisplayError($res == 0,"Cannot set user")
  50.    Sleep(1000)
  51.    ; Жмём Finish
  52.    $res = ControlClick($hWnd,"","[CLASS:TcxButton;TEXT:Finish]")
  53.    DisplayError($res == 0,"Cannot click finish")
  54.    ; Ждем пока лист прибудет
  55.    Sleep($getListTimeout*1000)
  56.  
  57. #cs
  58.    ; почемуто не получается нажать Start To Download Pictures по хендлу контрола
  59.    $hMainMenu = ControlGetHandle($hWnd,"[CLASS:TdxBarControl]","")
  60.    DisplayError($hMainMenu == 0,"Cannot get main menu handle")
  61.    ;$res = ControlClick($hWnd,"",$hMainMenu,"right",1,15,15)
  62.    ;DisplayError($res == 0,"Cannot click start downloading pictures")
  63. #ce
  64.  
  65.    ; жмём Start To Download Pictures
  66.    WinActivate($hWnd)
  67.    Sleep(500)
  68.    $windowPos = WinGetPos($hWnd)
  69.    MouseClick("left",$windowPos[0]+59,$windowPos[1]+25+13)
  70.  
  71. #cs
  72.    ; закрывалка тоже не работает
  73.    Local $hPage = ControlGetHandle($hWnd,"[CLASS:TcxTabSheet;INSTANCE:2]","")
  74.    DisplayError($hPage == 0,"Cannot get page handle")
  75.    $res = ControlClick($hWnd,"",$hPage,"left",70,12)
  76.    DisplayError($res == 0,"Cannot close page")
  77.    ConsoleWrite($hPage)
  78. #ce
  79.  
  80.    ; Пытаемся закрыть лист, если всплывает ошибка (ещё качается)
  81.    ; закрываем сообщение об ошибке и спим ещё таймаут
  82.    ; если ошибка не всплывает значит всё скачалось, можно выходить из цикла и функции
  83.    Do
  84.       Sleep($downloadTimeout*1000)
  85.       WinActivate($hWnd)
  86.       Sleep(500)
  87.       $windowPos = WinGetPos($hWnd)
  88.       $pagePos = ControlGetPos($hWnd,"","[CLASS:TcxPageControl]")
  89.       MouseClick("left",$windowPos[0]+$pagePos[0]+73,$windowPos[1]+$pagePos[1]+12+25)
  90.       Sleep(500)
  91.       $hError = WinGetHandle("[CLASS:TMessageForm]")
  92.       If $hError <> 0 Then
  93.          $res = ControlClick($hError,"","[CLASS:TButton]")
  94.       Else
  95.          ExitLoop
  96.       EndIf
  97.    Until False
  98.  
  99. EndFunc
  100.  
  101. ; Main
  102. Init()
  103. Local $userId
  104. For $userId in $userIds
  105.    DownloadUser($userId)
  106. Next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement