Что нового

[Автоматизация] Автоматическая установка HttpAnalyzerFull_V7

alex33

Скриптер
Сообщения
1,457
Репутация
186
AutoIt: 3.3.8.1
Версия: 1.0

Категория: Администрирование, Автоматизация

Описание: Рабочий пример автоустановки приложения HttpAnalyzerFull в основном для того что бы показать как это делается.
Основной код писался под тихую музыку и под чашку кофе, за это время я перезагружал компьютер 7 раз. :smile:

Код/Пример: (так же есть в архиве)
Код:
; Auto_installer.au3
If MsgBox(4, "AutoInstaller", "Автоматическая установка HttpAnalyzerFull_V7"&@CRLF&"          Установить / Продолжить?") = 7 Then Exit
_WinAPI_LoadKeyboardLayoutEx(0x0409)
Dim $filepath = @ScriptDir&"\HttpAnalyzerFull_V7.exe"
If Not FileExists($filepath) Then
MsgBox(0, "Error", $filepath&@CRLF&"File not exists")
Exit
;
EndIf
Dim $RegRestartPath = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"
RegDelete($RegRestartPath, "AutoInstaller")
Dim $title = "Setup - HTTPAnalyzer Full Edition V7.0.2"
Dim $aText[9]
$aText[0] = "Welcome to the HTTPAnalyzer"
$aText[1] = "License Agreement"
$aText[2] = "Select Destination Location"
$aText[3] = "Select Start Menu Folder"
$aText[4] = "Select Additional Tasks"
$aText[5] = "Ready to Install"
$aText[6] = "Installing"
$aText[7] = "Completing the HTTPAnalyzer Full"
$aText[8] = "After restarting your computer, run Setup again to complete the installation of"
Dim $eWin = "[TITLE:Folder Exists; CLASS:#32770]"
Dim $runpid = Run($filepath)
Dim $cError = 0
WinWait($title, $aText[0], 30)
If Not WinExists($title, $aText[0]) Then Exit 1
Sleep(500)
_WinAPI_LoadKeyboardLayoutEx(0x0409, WinGetHandle($title))
$cError = ControlSend($title, $aText[0], "", "!n") ; ; Next >
If Not _ch(0, $cError) Then _Error2Exit()
Sleep(500)
$cError = ControlSend($title, $aText[1], "", "!A") ; I accept
$cError = ControlSend($title, $aText[1], "", "!n") ; ; Next >
If Not _ch(1, $cError) Then _Error2Exit()
Sleep(500)
;;;;; ControlSetText($title, $aText[2], "TEdit1", "C:\MyProgramLocation")
$cError = ControlSend($title, $aText[2], "", "!n") ; Next >
If Not _ch(2, $cError) Then _Error2Exit()
Sleep(500)
If WinExists($eWin) Then
ControlClick($eWin, "", "Button1", "main")
Sleep(500)
EndIf
;;;;; ControlSetText($title, $aText[3], "TNewEdit1", "MyStart_MenuFolder")
$cError = ControlSend($title, $aText[3], "", "!n") ; Next >
If Not _ch(3, $cError) Then _Error2Exit()
Sleep(500)
$cError = ControlSend($title, $aText[4], "", "c") ; Checkbox focus
$cError = ControlSend($title, $aText[4], "", "{space}") ; unchecked
$cError = ControlSend($title, $aText[4], "", "a") ; Checkbox focus
$cError = ControlSend($title, $aText[4], "", "{space}") ; unchecked
$cError = ControlSend($title, $aText[4], "", "!n") ; Next >
If Not _ch(4, $cError) Then _Error2Exit()
Sleep(500)
$cError = ControlSend($title, $aText[5], "", "!i") ; Install
If Not _ch(5, $cError) Then _Error2Exit()
Sleep(1000)
If WinExists($title, $aText[8]) Then
WinClose($title, $aText[8]) ; Cancel
MsgBox(0, "Restart - AutoInstaller", "Требуется перезагрузка компьютера", 60)
RegWrite($RegRestartPath, "AutoInstaller", "REG_SZ", @ScriptFullPath & " /c")
Shutdown(6)
Exit
EndIf
If WinExists($title, $aText[6]) Then WinWait($title, $aText[7], 120)
$cError = ControlSend($title, $aText[7], "", "!f") ; Finish
If Not _ch(7, $cError) Then _Error2Exit()
MsgBox(0, "AutoInstaller", "Установка HttpAnalyzerFull_V7 успешно завершена")

; функция переключения раскладки клавиатуры
Func _WinAPI_LoadKeyboardLayoutEx($sLayoutID = 0x0409, $hWnd = 0)
Local Const $WM_INPUTLANGCHANGEREQUEST = 0x50
Local $aRet = DllCall("user32.dll", "long", "LoadKeyboardLayoutW", "wstr", Hex($sLayoutID, 8), "int", 0)
If Not @error And $aRet[0] Then
If $hWnd = 0 Then
$hWnd = WinGetHandle(AutoItWinGetTitle())
EndIf
DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hWnd, "int", $WM_INPUTLANGCHANGEREQUEST, "int", 1, "int", $aRet[0])
Return 1
EndIf
Return SetError(1)
EndFunc

; функции проверки и выхода при неудачи
Func _ch($aNumber, $ControlError = 0)
If Not IsNumber($ControlError) And Not IsNumber($aNumber) Then Return SetError(1, 0, 0)
If Not WinExists($title, $aText[$aNumber]) And $ControlError < 1 Then Return 0
Return 1
EndFunc
Func _Error2Exit()
MsgBox(16, "Error script - AutoInstaller", "Ошибка скрипта: не удалось найти элемент")
WinSetState($title, "", @SW_SHOW)
WinActivate($title)
Exit 2
EndFunc

Код:
; Auto_uninstaller.au3
Dim $regpath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{8DF9C507-AB88-43E4-A4F0-E2E493C4B0CE}_is1"
Dim $DisplayName = RegRead($regpath, "DisplayName")
Dim $DisplayVersion = RegRead($regpath, "DisplayVersion")
Dim $InstallLocation = RegRead($regpath, "InstallLocation")
Dim $QuietUninstallString = RegRead($regpath, "QuietUninstallString")
Dim $UninstallString = RegRead($regpath, "UninstallString")
Dim $cOk = 0
If $DisplayName <> "" And $DisplayVersion <> "" And $QuietUninstallString <> "" And $UninstallString <> "" Then $cOk = 1
If $cOk = 0 Then
MsgBox(0, "AutoUninstaller", "Программа не установлена")
Exit
EndIf
If MsgBox(4, "AutoUninstaller", "Удалить "&$DisplayName&" с компьютера?") = 7 Then Exit
Run($QuietUninstallString)
$title = "HTTPAnalyzer Full Edition V7.0.2 Uninstall"
$text = "To complete the uninstallation of HTTPAnalyzer Full Edition V7.0.2, your computer must be restarted."
WinWaitActive($title, $text, 120)
If WinExists($title, $text) Then
MsgBox(0, "AutoUninstaller", "Программа "&$DisplayName&" успешно удалена"&@CRLF&"Требуется перезагрузка компьютера", 60)
ControlClick($title, $text, "Button1", "Main") ; Yes
EndIf

Файл: Universal_AutoInstaller_HttpAnalyzerFull_V7_plus_demo_video.zip

Снимок:
Нет, но зато есть demo video в архиве

История версий:
1.0 - Первый выпуск

Источник: autoit-script.ru
Автор(ы): alex33
 
Верх