Advertisement
Guest User

Untitled

a guest
Aug 11th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 7.62 KB | None | 0 0
  1. #include <GUIConstants.au3>
  2. #include <WinAPIEx.au3>
  3.  
  4. Global $srv1 = "Главное управление №8", $srv2 = "Спецстрой России(Москва)", $srv3 = "Департамент строительства МО", $srv4 = "Главное управление №8(192.168.0.21)", $list1, $list2, $list3, $list4, $server
  5.  
  6. Global $title = "Настройка TrueConf v.1.0"
  7.  
  8. $Form1_1 = GUICreate($title, 354, 372, 821, 257) ;Создаем окно
  9. $Button1 = GUICtrlCreateButton("Подключиться", 109, 345, 129, 25) ;Создаем кнопку
  10. GUICtrlCreateGroup("Выберите учетную запись", 3, 170, 350, 120)
  11. $Combo1 = GUICtrlCreateCombo("", 18, 190, 320, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $CBS_DROPDOWNLIST)) ;Создаем выпадающий список
  12. GUICtrlSendMsg(-1, $CB_SETDROPPEDWIDTH, 320, 0) ;
  13. GUICtrlCreateGroup("", -99, -99, 1, 1) ; закрывает группу
  14. GUISetState(@SW_SHOW) ;Состояние окна(Показывать)
  15. GUICtrlCreateGroup("", 3, 0, 350, 150)
  16. $Radio1 = GUICtrlCreateRadio($srv1, 8, 24, 235, 16) ;Создаем радиокнопку
  17. $Radio2 = GUICtrlCreateRadio($srv2, 8, 55, 235, 16)
  18. $Radio3 = GUICtrlCreateRadio($srv3, 8, 85, 285, 16)
  19. $Radio4 = GUICtrlCreateRadio($srv4, 8, 118, 285, 16)
  20. GUICtrlCreateGroup("", -99, -99, 1, 1) ; закрывает группу
  21. Global $izh1Ping="195.88.198.247"
  22. Global $izh2Ping="192.168.0.21"
  23. Global $MoscowPing="212.46.251.150"
  24. Global $MOPing="188.128.123.60"
  25. $DataPath=@ScriptDir & "\etc\data.ini"
  26. Global $hKey
  27. $hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'SOFTWARE\TrueConf')
  28. If Not $hKey Then
  29.     MsgBox(16, $title, 'TrueConf Не найден!' & @CRLF & "Установите клиент TrueConf!")
  30.     GUIDelete()
  31.     Exit
  32. EndIf
  33.  
  34. $arr = IniReadSection($DataPath, $srv1) ;Читаем данные из файла data.ini из секции Сервер1
  35. For $i = 1 To $arr[0][0]
  36.   $list1 &= "|" & $arr[$i][0]
  37. Next
  38. $arr = IniReadSection($DataPath, $srv2)
  39. For $i = 1 To $arr[0][0]
  40.   $list2 &= "|" & $arr[$i][0]
  41. Next
  42. $arr = IniReadSection($DataPath, $srv3)
  43. For $i = 1 To $arr[0][0]
  44.   $list3 &= "|" & $arr[$i][0]
  45. Next
  46.  
  47. $arr = IniReadSection($DataPath, $srv4)
  48. For $i = 1 To $arr[0][0]
  49.   $list4 &= "|" & $arr[$i][0]
  50. Next
  51. ;MsgBox(0,"",$DataPath)
  52. _RefreshSystemTray(100)
  53. While 1
  54.   Switch GUIGetMsg()
  55.     Case $GUI_EVENT_CLOSE
  56.       Exit
  57.    Case $Button1
  58.       If ProcessExists("TrueConf.exe") Then
  59.          ProcessClose("TrueConf.exe")
  60.       EndIf
  61.        Run(@ProgramFilesDir & "\TrueConf Client\TrueConf.exe")
  62.        ServerSelect()
  63.       ; Активация клиента
  64.       $client = WinWait("TrueConf Client")
  65.       WinActivate($client)
  66.       Send("{ALT}{ENTER}")
  67.       Sleep(500)
  68.       ;MsgBox(0,"","Выполняю функцию Login")
  69.       Login(GUICtrlRead($Combo1))
  70.       _RefreshSystemTray(100)
  71.       Exit
  72.       GUIDelete()
  73.     Case $Radio1
  74.       PingSrv($izh1Ping)
  75.       GUICtrlSetData( $Combo1, $list1)
  76.       $server = $srv1
  77.    Case $Radio2
  78.       PingSrv($MoscowPing)
  79.       GUICtrlSetData($Combo1, $list2)
  80.       $server = $srv2
  81.    Case $Radio3
  82.       PingSrv($MOPing)
  83.       GUICtrlSetData($Combo1, $list3)
  84.       $server = $srv3
  85.    Case $Radio4
  86.       PingSrv($izh2Ping)
  87.       GUICtrlSetData($Combo1, $list4)
  88.       $server = $srv4
  89.   EndSwitch
  90. WEnd
  91.  
  92. Func ServerSettings($IP,$Port)
  93.   ; Активация клиента
  94. $client = WinWait("TrueConf Client")
  95. WinActivate($client)
  96. Send("{ALT}{LEFT 3}")
  97. sleep(500)
  98. send("{DOWN 3}")
  99. Sleep(500)
  100. Send("{Enter}")
  101. Sleep(500)
  102. $NetworkWin=WinWait("Сетевые настройки")
  103. WinActivate($NetworkWin)
  104. if ControlCommand($NetworkWin,"","[CLASS:TCheckBox; INSTANCE:3]","IsChecked") Then
  105.    Send("{SPACE}")
  106.    ControlClick($NetworkWin, "", "[CLASS:TButton; INSTANCE:2]")
  107. Else
  108.    ControlClick($NetworkWin, "", "[CLASS:TButton; INSTANCE:2]")
  109. EndIf
  110.    $ServerWin = WinWait("Сервер")
  111.    WinActivate($Server)
  112.    Sleep(500)
  113.    ControlSetText($ServerWin, "", "[CLASS:TEdit; INSTANCE:3]", $IP)
  114.    Sleep(500)
  115.    ControlSetText($ServerWin, "", "[CLASS:TEdit; INSTANCE:4]", $Port)
  116.    Sleep(500)
  117.    ControlClick($ServerWin, "", "[CLASS:TButton; INSTANCE:3]")
  118.    WinWait("Сетевые настройки")
  119.    WinActivate($NetworkWin)
  120.    ControlClick($NetworkWin, "", "[CLASS:TButton; INSTANCE:5]")
  121. EndFunc
  122.  
  123. Func ServerSelect()
  124.    If GUICtrlRead ($Radio1) = $GUI_CHECKED Then
  125.       ;RunWait(@ComSpec & ' /C regedit /s"' & @ScriptDir & '\etc\Izh_External.reg"', '', @SW_HIDE)
  126.       ServerSettings($Izh1Ping,"44307")
  127.    EndIf
  128.    If GUICtrlRead ($Radio2) = $GUI_CHECKED Then
  129.       ;RunWait(@ComSpec & ' /C regedit /s"' & @ScriptDir & '\etc\Moscow.reg"', '', @SW_HIDE)
  130.       ServerSettings($MoscowPing,"4307")
  131.    EndIf
  132.    If GUICtrlRead ($Radio3) = $GUI_CHECKED Then
  133.       ;RunWait(@ComSpec & ' /C regedit /s"' & @ScriptDir & '\etc\Depart_Build_MO.reg"', '', @SW_HIDE)
  134.       ServerSettings($MOPing,"4307")
  135.    EndIf
  136.    If GUICtrlRead ($Radio4) = $GUI_CHECKED Then
  137.       ;RunWait(@ComSpec & ' /C regedit /s"' & @ScriptDir & '\etc\Izh.reg"', '', @SW_HIDE)
  138.       ServerSettings($Izh2Ping,"4307")
  139.    EndIf
  140. EndFunc
  141.  
  142. Func Login($nick)
  143.   Local $data = StringSplit(IniRead($DataPath, $server, $nick, ''), "|")
  144.   If @error Then Return
  145.   Local $user = $data[1], $pass = $data[2]
  146.   ;MsgBox(0,"","Вводим логин и пароль")
  147.   Opt("WinTitleMatchMode", 2)
  148.   $login = WinWait("авторизация", "")
  149.   WinActivate($login)
  150.   Sleep(200) ; Дождаться, когда контролы станут активны
  151.   ControlSetText($login, "", "[CLASS:TEdit; INSTANCE:2]", $user) ; Поле с именем
  152.   ControlSetText($login, "", "[CLASS:TEdit; INSTANCE:1]", $pass) ; Поле с паролем
  153.   ControlClick($login, "", "[CLASS:TButton; INSTANCE:1]") ; Кнопка
  154. EndFunc
  155.  
  156. Func _RefreshSystemTray($nDelay = 1000)
  157.     ; Save Opt settings
  158.     Local $oldMatchMode = Opt("WinTitleMatchMode", 4)
  159.     Local $oldChildMode = Opt("WinSearchChildren", 1)
  160.     Local $error = 0
  161.     Do; Pseudo loop
  162.         Local $HWindow = WinGetHandle("classname=TrayNotifyWnd")
  163.         If @error Then
  164.             $error = 1
  165.             ExitLoop
  166.         EndIf
  167.         Local $hControl = ControlGetHandle($HWindow, "", "Button1")
  168.         ; We're on XP and the Hide Inactive Icons button is there, so expand it
  169.         If $hControl <> "" And ControlCommand($HWindow, "", $hControl, "IsVisible", "") Then
  170.             ControlClick($HWindow, "", $hControl)
  171.             Sleep($nDelay)
  172.         EndIf
  173.         Local $posStart = MouseGetPos()
  174.         Local $posWin = WinGetPos($HWindow)
  175.         Local $y = $posWin[1]
  176.         While $y < $posWin[3] + $posWin[1]
  177.             Local $x = $posWin[0]
  178.             While $x < $posWin[2] + $posWin[0]
  179.                 DllCall("user32.dll", "int", "SetCursorPos", "int", $x, "int", $y)
  180.                 If @error Then
  181.                     $error = 2
  182.                     ExitLoop 3; Jump out of While/While/Do
  183.                 EndIf
  184.                 $x = $x + 8
  185.             WEnd
  186.             $y = $y + 8
  187.         WEnd
  188.         DllCall("user32.dll", "int", "SetCursorPos", "int", $posStart[0], "int", $posStart[1])
  189.         ; We're on XP so we need to hide the inactive icons again.
  190.         If $hControl <> "" And ControlCommand($HWindow, "", $hControl, "IsVisible", "") Then
  191.             ControlClick($HWindow, "", $hControl)
  192.         EndIf
  193.     Until 1
  194.     ; Restore Opt settings
  195.     Opt("WinTitleMatchMode", $oldMatchMode)
  196.     Opt("WinSearchChildren", $oldChildMode)
  197.     SetError($error)
  198.  EndFunc   ;==>_RefreshSystemTray
  199.  
  200. Func PingSrv($SrvPing)
  201.    if Not Ping($SrvPing,1) Then
  202.       MsgBox(16,$title,"Сервер недоступен!")
  203.       Exit
  204.       GUIDelete()
  205.    EndIf
  206. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement