Must AutoIt
Сообщения: 3054
Благодарности: 1009
|
Профиль
|
Сайт
|
Отправить PM
| Цитировать
Shpionus, Вобщем вот что получилось (полная установка программы):
Friendly Pinger Installer Script.au3
Код: 
#include <GUIMenu.au3>
#include <WindowsConstants.au3>
;Friendly Pinger installation script (by G.Sandler, a.k.a CreatoR)
#Region ============= Settings ============
Global $sUserName = "User"
Global $sKey = "Key"
Global $sInstall_Path = "Default" ;Default will not change the path suggested by installer
Global $nLangSel = 2 ;Set the language selection (2 is russian, 0 = default - english)
Global $iBlockInput = 0 ;Block the user input during installation (1 -> block, 0 -> Do not block)
#EndRegion ==================================
;
#Region ============= Script =============
Run(@ScriptDir & "\FPinger_5_0.exe")
If @error Then Exit
If $iBlockInput Then BlockInput(1)
;Wait for the first window
WinWait("[CLASS:obj_Form;TITLE:Friendly Pinger]")
;Click Next button
ControlClick("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_BUTTON29")
;Select "I accept the agreement"
ControlClick("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_BUTTON6")
;Click Next button
ControlClick("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_BUTTON29")
;Set the install path if neccessary
If $sInstall_Path <> "Default" Then
ControlSetText("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_EDIT5", $sInstall_Path)
Else
$sInstall_Path = ControlGetText("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_EDIT5")
EndIf
;Select the language
ControlFocus("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_COMBOBOX1")
ControlSend("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_COMBOBOX1", "{HOME}")
If $nLangSel > 0 Then ControlSend("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_COMBOBOX1", "{DOWN " & $nLangSel & "}")
;Click Next button
ControlClick("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_BUTTON29")
ControlClick("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_BUTTON29")
;Wait untill the installation is completed
While 1
If WinExists("[CLASS:obj_Form;TITLE:Friendly Pinger]", "Installation complete!") Then ExitLoop
If WinExists("[CLASS:#32770;TITLE:Friendly Pinger]", "Old template-files are stored in") Then
WinClose("[CLASS:#32770;TITLE:Friendly Pinger]", "Old template-files are stored in")
WinWaitClose("[CLASS:#32770;TITLE:Friendly Pinger]", "Old template-files are stored in")
EndIf
Sleep(100)
WEnd
;Remove not needed(?) checkboxes
ControlCommand("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_BUTTON25", "Check")
ControlCommand("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_BUTTON26", "UnCheck")
ControlCommand("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_BUTTON27", "UnCheck")
;Click Finish button
ControlClick("[CLASS:obj_Form;TITLE:Friendly Pinger]", "", "obj_BUTTON29")
;Wait for Trial message window
WinWait("[CLASS:TToRegistryForm;TITLE:Friendly Pinger]")
;Get the button number to click
$nButton = ControlGetText("[CLASS:TToRegistryForm;TITLE:Friendly Pinger]", "", "TGroupBox1")
$nButton = Number(StringRegExpReplace($nButton, "(?i).*?(?:Nr.|№ )(\d+).*?", "\1"))
;Click the button to confirm the trial
ControlClick("[CLASS:TToRegistryForm;TITLE:Friendly Pinger]", "", "TButton" & 4-$nButton)
;Wait for main window to be active
WinWait("[CLASS:TFPingerMainForm]", "", 3)
WinActivate("[CLASS:TFPingerMainForm]")
WinWaitActive("[CLASS:TFPingerMainForm]", "", 3)
;No we click the Register item in menu
$hWnd = WinGetHandle("[CLASS:TFPingerMainForm]")
$hMenu = _GUICtrlMenu_GetMenu($hWnd)
$hHelp = _GUICtrlMenu_GetItemSubMenu($hMenu, 8) ;Help menu
$iItemID = _GUICtrlMenu_GetItemID($hHelp, 11) ;Third item from the bottom (zero-based)
;English (perhaps other as well) version have it a little bit up then in russian version
If $nLangSel <= 0 Then $iItemID = _GUICtrlMenu_GetItemID($hHelp, 10)
DllCall("User32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", $WM_COMMAND, "int", $iItemID, "int", 0)
WinWaitActive("[CLASS:TRegisterForm;TITLE:Registration]", "", 3)
;If the registration window showed up, set the user name and the key, and then restart
If WinExists("[CLASS:TRegisterForm;TITLE:Registration]") Then
ControlSetText("[CLASS:TRegisterForm]", "", "TEdit1", $sUserName)
ControlSetText("[CLASS:TRegisterForm]", "", "TEdit2", $sKey)
ControlClick("[CLASS:TRegisterForm]", "", "TBitBtn3")
;Restart the program
WinClose($hWnd)
WinWaitClose($hWnd)
Run($sInstall_Path & "\FPinger.exe")
EndIf
If $iBlockInput Then BlockInput(0)
#EndRegion ============= Script =============
;
P.S
Я обычно не занимаюсь подобными скриптами, но у меня просто было пару свободных минут 
|