Что нового

[Автоматизация] Останавливается скрипт после условного перехода (If,Else,EndIf)

warezoogle3

Новичок
Сообщения
73
Репутация
1
Дождались!
С помощью ОГРОМНОЙ поддержки и помощи участников,модераторов,супермотераторов и администраторов сделал наконец-то свой скрипт!
СПАСИБО ВАМ ОГРОМНОЕ,ДОБРЫЕ ЛЮДИ! :beer: :IL_AutoIt_1:
Но (как и всегда у новичков) заметил,что некоторые вещи не работают! ;D
В общем,более подробно:

Код:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#RequireAdmin

;собственно GUI скрипта
#region ### START Koda GUI section ### 
$Form1_1 = GUICreate("Zinguilla 6 Sigma Edition", 464, 453, 288, 125)
$Label1 = GUICtrlCreateLabel(" Zinguilla 6 Sigma Edition", 80, 32, 288, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$Button1 = GUICtrlCreateButton("Change Regional Settings", 144, 152, 171, 25) ;первая кнопка
$Button2 = GUICtrlCreateButton("Install Zinguilla 6 Sigma Edition", 144, 248, 171, 25) ;вторая кнопка
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\Zinguilla_logo.jpg", 80, 72, 292, 68) ;логотип
$Label2 = GUICtrlCreateLabel("Warning! After pressing the Change Regional Settings button your computer may restart!", 24, 192, 418, 17)
$Label3 = GUICtrlCreateLabel("Please save all unsaved data and close all running programs!", 88, 216, 292, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ### 

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			Button1Click() 
		Case $Button2
			Button2Click() 

	EndSwitch
WEnd

Func Button1Click() ;код первой кнопки
	;меняем региональные настройки
	If @OSVersion = "WIN_XP" Then ;для Windows XP
		Run(@ComSpec & " /c start " & @SystemDir & "\intl.cpl") 
		WinWait('Regional and Language Options')
		$hTab = ControlGetHandle('Regional and Language Options', '', 'SysTabControl321')
		$tIndex = _GUICtrlTab_FindTab($hTab, 'Regional Options', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex)
		ControlCommand("Regional and Language Options", "Standards and formats", 1021, "SelectString", 'English (United States)')
		ControlClick("Regional and Language Options", "Standards and formats", "Button6")
		ControlCommand("Regional and Language Options", "Location", 1023, "SelectString", 'United States')
		ControlClick("Regional and Language Options", "Location", "Button6")
		Sleep(1000)
		$tIndex2 = _GUICtrlTab_FindTab($hTab, 'Advanced', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex2)
		ControlCommand("Regional and Language Options", "Language for non-Unicode programs", 1052, "SelectString", 'English (United States)')
		ControlClick("Regional and Language Options", "Language for non-Unicode programs", "Button7")
	Else ;для Windows Vista,7
		Run(@ComSpec & " /c start " & @SystemDir & "\intl.cpl") ;меняем региональные настройки
		WinWait('Region and Language')
		$hTab = ControlGetHandle('Region and Language', '', 'SysTabControl321')
		$tIndex = _GUICtrlTab_FindTab($hTab, 'Formats', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex)
		ControlCommand("Region and Language", "Formats", 1021, "SelectString", 'English (United States)')
		ControlClick("Region and Language", "Formats", "Button6")
		Sleep(1000)
		$tIndex2 = _GUICtrlTab_FindTab($hTab, 'Location', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex2)
		ControlCommand("Region and Language", "Current location", 1023, "SelectString", 'United States')
		ControlClick("Region and Language", "Current location", "Button3")
		Sleep(1000)
		$tIndex3 = _GUICtrlTab_FindTab($hTab, 'Administrative', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex3)
		ControlClick("Region and Language", "Language for non-Unicode programs", "Button4")
		WinWaitActive("Region and Language Settings", "Current system locale")
		WinActivate("Region and Language Settings", "Current system locale")
		ControlCommand("Region and Language Settings", "Current system locale", 1052, "SelectString", 'English (United States)')
		ControlClick("Region and Language Settings", "Current system locale", "Button1")
	EndIf
EndFunc

Func Button2Click() ;код второй кнопки

	;инсталлируем шрифты и директории скрипта
	Const $FONTS = 0x14 

	$oShell = ObjCreate("Shell.Application")
	$oWinFonts = $oShell.Namespace($FONTS)

	;Шрифты должны быть в той же директории
	$sFirstFile = FileFindFirstFile("*.*")

	If $sFirstFile = -1 Then
		Exit
	EndIf

	While 1
		Local $sFile = FileFindNextFile($sFirstFile)
		If @error Then ExitLoop
		Switch StringRight($sFile, 3)
			Case 'ttf', 'otf', 'pfm', 'fon'
				$sWinFontsPath = @WindowsDir & '\Fonts\' & $sFile
				$sLocFontsPath = @ScriptDir & '\' & $sFile
				If Not FileExists($sWinFontsPath) Then
					$oWinFonts.CopyHere($sLocFontsPath)
				Else
					MsgBox(262144, $sFile, 'The font is already installed', 1)
				EndIf
		EndSwitch
	WEnd

	AutoItSetOption("WinTitleMatchMode", 2)
	AutoItSetOption("WinDetectHiddenText", 1)

	WinMinimizeAll()

	Sleep(1000)

	;Запускаем программу установки и начинаем инсталлировать
	Run('Zinguilla6_Setup.exe') 

	$WinTitle = "Zinguilla 6 Sigma Edition - InstallShield Wizard"

	WinWaitActive($WinTitle, "Welcome to the InstallShield Wizard for LSBANK 6.0 VTB Edition")
	WinActivate($WinTitle, "Welcome to the InstallShield Wizard for Zinguilla 6 Sigma Edition")
	Send('{ENTER}')

	WinWaitActive($WinTitle, "Customer Information")
	WinActivate($WinTitle, "Customer Information")
	ControlSetText($WinTitle, "Customer Information", "Edit1", "CKD626U")
	ControlSetText($WinTitle, "Customer Information", "Edit2", "6W1K")
	ControlSetText($WinTitle, "Customer Information", "Edit3", "FLFJ")
	ControlSetText($WinTitle, "Customer Information", "Edit4", "QWD9")
	ControlSetText($WinTitle, "Customer Information", "Edit5", "BKG06C4AC")
	ControlClick($WinTitle, "", "Button5")

	WinWaitActive($WinTitle, "Ready to Install the Program")
	WinActivate($WinTitle, "Ready to Install the Program")
	ControlClick($WinTitle, "", "Button6")
	ControlClick($WinTitle, "", "Button1")

	;На Windows 7 при установке появляется процесс MSI***.TMP,
	;где *** случайные цифры,и вешает установку,
	;но если удалить процесс,то установка продолжается,поэтому удаляем процесс
	If @OSVersion = "WIN_7" Then 
		Sleep(3000)
		$PIDs = ProcessList()
		For $i = 1 To $PIDs[0][0]
			$Reg = StringRegExp($PIDs[$i][0], 'MSI.*\.tmp', 3)
			If $Reg <> 1 Then
				If ProcessExists($PIDs[$i][1]) Then ProcessClose($PIDs[$i][1])
			EndIf
		Next
	EndIf

	Sleep(1000)

	WinWaitActive($WinTitle, "InstallShield Wizard Completed")
	WinActivate($WinTitle, "InstallShield Wizard Completed")
	Send('{ENTER}')

	Sleep(5000)
	
    ;Устанавливаем тему
	If @OSVersion = "WIN_XP" Then ;для Windows XP
		$theme = @ScriptDir & "\KDW ARM_XP.Theme"
		ShellExecute($theme, "", "", "open", @SW_HIDE)
		WinWaitActive("Display Properties")
		WinActivate("Display Properties")
		ControlClick("Display Properties", "", "Button5")
		ControlClick("Display Properties", "", "Button3")

	Else ;для Windows Vista,7
		WinWaitActive("Control Panel\All Control Panel Items\Personalization")
		WinActivate("Control Panel\All Control Panel Items\Personalization")
		WinClose("Control Panel\All Control Panel Items\Personalization")

		Sleep(3000)

		$theme = @ScriptDir & "\Win 7 Blue New.themepack"
		ShellExecute($theme, "", "", "open", @SW_HIDE)
		WinWaitActive("Control Panel\All Control Panel Items\Personalization")
		WinActivate("Control Panel\All Control Panel Items\Personalization")
		WinClose("Control Panel\All Control Panel Items\Personalization")
	EndIf

	;Меняем конфигурацию
	$sPath = @CommonFilesDir & '\Borland Shared\BDE\idapi32.cfg' 

	If FileCopy(@ScriptDir & '\idapi32.cfg', $sPath, 9) Then
	Else
		If Not FileSetAttrib($sPath, '-RST') Then
			MsgBox(16, 'Error', 'FileSetAttrib')
			Exit -33
		Else
			If Not FileCopy(@ScriptDir & '\idapi32.cfg', $sPath, 9) Then
				MsgBox(16, 'Error', 'FileCopy')
				Exit -44
			EndIf
		EndIf
	EndIf

	$__msgbox = MsgBox(0, 'Zinguilla 6 Sigma Edition', 'Setup done')

EndFunc   

Exit


Вроде все должно нормально работать (и работало),но вот при добавлении все большего количества код в скрипт, на этой части скрипта
Код:
;На Windows 7 при установке появляется процесс MSI***.TMP,
	;где *** случайные цифры,и вешает установку,
	;но если удалить процесс,то установка продолжается,поэтому удаляем процесс
	If @OSVersion = "WIN_7" Then 
		Sleep(3000)
		$PIDs = ProcessList()
		For $i = 1 To $PIDs[0][0]
			$Reg = StringRegExp($PIDs[$i][0], 'MSI.*\.tmp', 3)
			If $Reg <> 1 Then
				If ProcessExists($PIDs[$i][1]) Then ProcessClose($PIDs[$i][1])
			EndIf
		Next
	EndIf
где должно убиться процесс и продолжаться установка на Windows 7,скрипт останавливается и дальше не идет (на Windows XP все нормально,посколько по условному переходу речь о нем не идет)!
Заного собрать инсталлятор без появления процесса на Windows 7,не представляется возможным!

Никак не могу исправить!
Помогите пожалуйста,ДОБРЫЕ ЛЮДИ! :smile:
 

inververs

AutoIT Гуру
Сообщения
2,135
Репутация
465
Re: [Автоматизация] Не могу найти ошибку в скрипте

Процесс MSI***.TMP все таки убивается или нет?


Добавлено:
Сообщение автоматически объединено:

Если убивается то меняйте
Код:
WinWaitActive($WinTitle, "InstallShield Wizard Completed")

на
Код:
WinWait($WinTitle, "InstallShield Wizard Completed")



Добавлено:
Сообщение автоматически объединено:

Функция WinWaitActive будет ждать активации окна. Вы уверены что оно вам нужно. Замените все WinWaitActive на WinWait.
После WinWait делайте WinActivate и посылайте команды.



Добавлено:
Сообщение автоматически объединено:

И все конструкци
Код:
WinWaitActive("")
WinActivate("")

меняйте на
Код:
WinWait("")
WinActivate("")
WinWaitActive("")
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
Re: [Автоматизация] Не могу найти ошибку в скрипте

Предупреждение За нарушение правил форума (пункт Б.5):
Имя темы должно нести смысловую нагрузку (отражать суть вопроса/проблемы)
Правильно сформулированное название темы привлекает больше внимания, и шансы получить конкретный ответ увеличиваются.


Данные правила могут пополняться локальными правилами раздела.
Как правильно называть темы

"[Автоматизация] Не могу найти ошибку в скрипте" - это неприемлемое название темы, переименуйте тему иначе она будет закрыта, а вам возможно будет выдан бан на несколько дней.

С уважением, ваш Модератор.











Добавлено:
Сообщение автоматически объединено:

warezoogle3,
Это окно на нужной вкладке можно открыть так:
Код:
$iTab = Random(0, 2, 1)
ConsoleWrite($iTab & @LF)
#cs
Windows XP:
0 - вкладка Региональные параметры
1 - вкладка Языки
2 - вкладка Дополнительно
http://user.alexanderklimov.ru/tutorial/rundll32.php
#ce
Run('rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,' & $iTab)
 

agikon

Знающий
Сообщения
789
Репутация
17
консоль (F5) SciTE покажет какая ошибка мешает работе.
 
Автор
W

warezoogle3

Новичок
Сообщения
73
Репутация
1
inververs
Поменял все,как Вы сказали!
Теперь после этого
Код:
If @OSVersion = "WIN_7" Then
		Sleep(3000)
		$PIDs = ProcessList()
		For $i = 1 To $PIDs[0][0]
			$Reg = StringRegExp($PIDs[$i][0], 'MSI.*\.tmp', 3)
			If $Reg <> 1 Then
				If ProcessExists($PIDs[$i][1]) Then ProcessClose($PIDs[$i][1])
			EndIf
		Next
	EndIf

	Sleep(1000)

	WinWait($WinTitle, "InstallShield Wizard Completed")
	WinActivate($WinTitle, "InstallShield Wizard Completed")
	WinWaitActive($WinTitle, "InstallShield Wizard Completed")
	Send('{ENTER}')

весь последующий код,тоесть
Код:
Sleep(5000)
    
    ;Устанавливаем тему
    If @OSVersion = "WIN_XP" Then ;для Windows XP
        $theme = @ScriptDir & "\KDW ARM_XP.Theme"
        ShellExecute($theme, "", "", "open", @SW_HIDE)
        WinWaitActive("Display Properties")
        WinActivate("Display Properties")
        ControlClick("Display Properties", "", "Button5")
        ControlClick("Display Properties", "", "Button3")

    Else ;для Windows Vista,7
        WinWaitActive("Control Panel\All Control Panel Items\Personalization")
        WinActivate("Control Panel\All Control Panel Items\Personalization")
        WinClose("Control Panel\All Control Panel Items\Personalization")

        Sleep(3000)

        $theme = @ScriptDir & "\Win 7 Blue New.themepack"
        ShellExecute($theme, "", "", "open", @SW_HIDE)
        WinWaitActive("Control Panel\All Control Panel Items\Personalization")
        WinActivate("Control Panel\All Control Panel Items\Personalization")
        WinClose("Control Panel\All Control Panel Items\Personalization")
    EndIf

    ;Меняем конфигурацию
    $sPath = @CommonFilesDir & '\Borland Shared\BDE\idapi32.cfg' 

    If FileCopy(@ScriptDir & '\idapi32.cfg', $sPath, 9) Then
    Else
        If Not FileSetAttrib($sPath, '-RST') Then
            MsgBox(16, 'Error', 'FileSetAttrib')
            Exit -33
        Else
            If Not FileCopy(@ScriptDir & '\idapi32.cfg', $sPath, 9) Then
                MsgBox(16, 'Error', 'FileCopy')
                Exit -44
            EndIf
        EndIf
    EndIf

    $__msgbox = MsgBox(0, 'Zinguilla 6 Sigma Edition', 'Setup done')

EndFunc   

Exit

не выполняется на Windows 7!
На XP все работает!

madmasles
Так?
Код:
If @OSVersion = "WIN_XP" Then
	$iTab = (0)
	ConsoleWrite($iTab2 & @LF)
	Run('rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,' & $iTab)
	ControlCommand("Regional and Language Options", "Standards and formats", 1021, "SelectString", 'English (United States)')
	ControlClick("Regional and Language Options", "Standards and formats", "Button6")
	ControlCommand("Regional and Language Options", "Location", 1023, "SelectString", 'United States')
	ControlClick("Regional and Language Options", "Location", "Button6")
	Sleep(1000)
	$iTab2 = (2)
	ConsoleWrite($iTab2 & @LF)
	Run('rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,' & $iTab2)
	ControlCommand("Regional and Language Options", "Language for non-Unicode programs", 1052, "SelectString", 'English (United States)')
	ControlClick("Regional and Language Options", "Language for non-Unicode programs", "Button7")
Else
	$iTab3 = 0
	ConsoleWrite($iTab3 & @LF)
	Run('rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,' & $iTab3)
	ControlCommand("Region and Language", "Formats", 1021, "SelectString", 'English (United States)')
	ControlClick("Region and Language", "Formats", "Button6")
	Sleep(1000)
	$iTab4 = 1
	ConsoleWrite($iTab4 & @LF)
	Run('rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,' & $iTab4)
	ControlCommand("Region and Language", "Current location", 1023, "SelectString", 'United States')
	ControlClick("Region and Language", "Current location", "Button3")
	Sleep(1000)
	$iTab5 = 3
	ConsoleWrite($iTab5 & @LF)
	Run('rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,' & $iTab5)
	ControlClick("Region and Language", "Language for non-Unicode programs", "Button4")
	WinWaitActive("Region and Language Settings", "Current system locale")
	WinActivate("Region and Language Settings", "Current system locale")
	ControlCommand("Region and Language Settings", "Current system locale", 1052, "SelectString", 'English (United States)')
	ControlClick("Region and Language Settings", "Current system locale", "Button1")
EndIf

Но так ни ControlCommand с SelectString (не выбирается строка в combobox),ни ControlClick не работают (не нажимаются кнопки).


Добавлено:
Сообщение автоматически объединено:

Пожалуйста,помогите мне! :smile:
 

Yuri

AutoIT Гуру
Сообщения
737
Репутация
282
warezoogle3
Что будет, если это вырезать из скрипта
Код:
If @OSVersion = "WIN_7" Then 
	Sleep(3000)
	$PIDs = ProcessList()
	For $i = 1 To $PIDs[0][0]
		$Reg = StringRegExp($PIDs[$i][0], 'MSI.*\.tmp', 3)
		If $Reg <> 1 Then
			If ProcessExists($PIDs[$i][1]) Then ProcessClose($PIDs[$i][1])
		EndIf
	Next
EndIf

и затем вставить после строчки ?
Код:
Run('Zinguilla6_Setup.exe')
 
Автор
W

warezoogle3

Новичок
Сообщения
73
Репутация
1
Yuriy
Пробовал,как Вы сказали.
Скрипт останавливается и сного запускается установщик.
Пробовал также без
Код:
Run('Zinguilla6_Setup.exe')

тоже останавливается.

agikon
Консоль не помогла.
 

Yuri

AutoIT Гуру
Сообщения
737
Репутация
282
warezoogle3
Попробуй этот код, отвечающий за нахождение и завершение
процесса MSI ставить ниже - после нажатия Enter, затем,
если не помогло - после нажатия Button5, затем после Button6.
А ты проверял, процесс MSI завершается?
Пробовал также без Run('Zinguilla6_Setup.exe')
Понятно, ведь тогда установщик не запустится и WinWait
бесконечно будет ждать окна, которое не появится.
 
Автор
W

warezoogle3

Новичок
Сообщения
73
Репутация
1
Yuriy
Интересные вещи творятся!
Удалил эту часть кода вообще!
Код:
If @OSVersion = "WIN_7" Then 
    Sleep(3000)
    $PIDs = ProcessList()
    For $i = 1 To $PIDs[0][0]
        $Reg = StringRegExp($PIDs[$i][0], 'MSI.*\.tmp', 3)
        If $Reg <> 1 Then
            If ProcessExists($PIDs[$i][1]) Then ProcessClose($PIDs[$i][1])
        EndIf
    Next
EndIf

После этого установщик без проблем (без зависания) устанавил прогу на Windows 7!
Тоесть получается,что процесс вообще не мешает!
НО...

Остальной код (код ПОСЛЕ удаленного куска) вообще не выполняется!

Общий код скрипта:
Код:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#RequireAdmin

#region ### START Koda GUI section ###
$Form1_1 = GUICreate("Zinguilla 6 Sigma Edition", 464, 453, 288, 125)
$Label1 = GUICtrlCreateLabel(" Zinguilla 6 Sigma Edition", 80, 32, 288, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$Button1 = GUICtrlCreateButton("Change Regional Settings", 144, 152, 171, 25)
$Button2 = GUICtrlCreateButton("Zinguilla 6 Sigma Edition", 144, 248, 171, 25)
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\Zinguilla_logo.jpg", 80, 72, 292, 68)
$Label2 = GUICtrlCreateLabel("Warning! After pressing the Change Regional Settings button your computer may restart!", 24, 192, 418, 17)
$Label3 = GUICtrlCreateLabel("Please save all unsaved data and close all running programs!", 88, 216, 292, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			Button1Click()
		Case $Button2
			Button2Click()

	EndSwitch
WEnd

Func Button1Click()
	If @OSVersion = "WIN_XP" Then
		Run(@ComSpec & " /c start " & @SystemDir & "\intl.cpl")
		WinWait('Regional and Language Options')
		$hTab = ControlGetHandle('Regional and Language Options', '', 'SysTabControl321')
		$tIndex = _GUICtrlTab_FindTab($hTab, 'Regional Options', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex)
		ControlCommand("Regional and Language Options", "Standards and formats", 1021, "SelectString", 'English (United States)')
		ControlClick("Regional and Language Options", "Standards and formats", "Button6")
		ControlCommand("Regional and Language Options", "Location", 1023, "SelectString", 'United States')
		ControlClick("Regional and Language Options", "Location", "Button6")
		Sleep(1000)
		$tIndex2 = _GUICtrlTab_FindTab($hTab, 'Advanced', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex2)
		ControlCommand("Regional and Language Options", "Language for non-Unicode programs", 1052, "SelectString", 'English (United States)')
		ControlClick("Regional and Language Options", "Language for non-Unicode programs", "Button7")
	Else
		Run(@ComSpec & " /c start " & @SystemDir & "\intl.cpl")
		WinWait('Region and Language')
		$hTab = ControlGetHandle('Region and Language', '', 'SysTabControl321')
		$tIndex = _GUICtrlTab_FindTab($hTab, 'Formats', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex)
		ControlCommand("Region and Language", "Formats", 1021, "SelectString", 'English (United States)')
		ControlClick("Region and Language", "Formats", "Button6")
		Sleep(1000)
		$tIndex2 = _GUICtrlTab_FindTab($hTab, 'Location', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex2)
		ControlCommand("Region and Language", "Current location", 1023, "SelectString", 'United States')
		ControlClick("Region and Language", "Current location", "Button3")
		Sleep(1000)
		$tIndex3 = _GUICtrlTab_FindTab($hTab, 'Administrative', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex3)
		ControlClick("Region and Language", "Language for non-Unicode programs", "Button4")
		WinWaitActive("Region and Language Settings", "Current system locale")
		WinActivate("Region and Language Settings", "Current system locale")
		ControlCommand("Region and Language Settings", "Current system locale", 1052, "SelectString", 'English (United States)')
		ControlClick("Region and Language Settings", "Current system locale", "Button1")
	EndIf
EndFunc   

Func Button2Click()
	Const $FONTS = 0x14

	$oShell = ObjCreate("Shell.Application")
	$oWinFonts = $oShell.Namespace($FONTS)

	; Fonts must be in the same directory
	$sFirstFile = FileFindFirstFile("*.*")

	If $sFirstFile = -1 Then
		Exit
	EndIf

	While 1
		Local $sFile = FileFindNextFile($sFirstFile)
		If @error Then ExitLoop
		Switch StringRight($sFile, 3)
			Case 'ttf', 'otf', 'pfm', 'fon'
				$sWinFontsPath = @WindowsDir & '\Fonts\' & $sFile
				$sLocFontsPath = @ScriptDir & '\' & $sFile
				If Not FileExists($sWinFontsPath) Then
					$oWinFonts.CopyHere($sLocFontsPath)
				Else
					MsgBox(262144, $sFile, 'The font is already installed', 1)
				EndIf
		EndSwitch
	WEnd

	AutoItSetOption("WinTitleMatchMode", 2)
	AutoItSetOption("WinDetectHiddenText", 1)

	WinMinimizeAll()

	Sleep(1000)

	Run('Zinguilla 6 Sigma Edition')

	$WinTitle = "Zinguilla 6 Sigma Edition - InstallShield Wizard"

	WinWait($WinTitle, "Welcome to the InstallShield Wizard for Zinguilla 6 Sigma Edition")
	WinActivate($WinTitle, "Welcome to the InstallShield Wizard for Zinguilla 6 Sigma Edition")
	WinWaitActive($WinTitle, "Welcome to the InstallShield Wizard for Zinguilla 6 Sigma Edition")
	Send('{ENTER}')

	WinWait($WinTitle, "Customer Information")
	WinActivate($WinTitle, "Customer Information")
	WinWaitActive($WinTitle, "Customer Information")
	ControlSetText($WinTitle, "Customer Information", "Edit1", "CKD626U")
	ControlSetText($WinTitle, "Customer Information", "Edit2", "6W1K")
	ControlSetText($WinTitle, "Customer Information", "Edit3", "FLFJ")
	ControlSetText($WinTitle, "Customer Information", "Edit4", "QWD9")
	ControlSetText($WinTitle, "Customer Information", "Edit5", "BKG06C4AC")
	ControlClick($WinTitle, "", "Button5")

	WinWait($WinTitle, "Ready to Install the Program")
	WinActivate($WinTitle, "Ready to Install the Program")
	WinWaitActive($WinTitle, "Ready to Install the Program")
	ControlClick($WinTitle, "", "Button6")
	ControlClick($WinTitle, "", "Button1")

	WinWait($WinTitle, "InstallShield Wizard Completed")
	WinActivate($WinTitle, "InstallShield Wizard Completed")
	WinWaitActive($WinTitle, "InstallShield Wizard Completed")
	Send('{ENTER}')

	If @OSVersion = "WIN_XP" Then
		$theme = @ScriptDir & "\KDW ARM_XP.Theme"
		ShellExecute($theme, "", "", "open", @SW_HIDE)
		WinWait("Display Properties")
		WinActivate("Display Properties")
		WinWaitActive("Display Properties")
		ControlClick("Display Properties", "", "Button5")
		ControlClick("Display Properties", "", "Button3")

	Else
		WinWait("Control Panel\All Control Panel Items\Personalization")
		WinActivate("Control Panel\All Control Panel Items\Personalization")
		WinWaitActive("Control Panel\All Control Panel Items\Personalization")
		WinClose("Control Panel\All Control Panel Items\Personalization")

		Sleep(3000)

		$theme = @ScriptDir & "\Win 7 Blue New.themepack"
		ShellExecute($theme, "", "", "open", @SW_HIDE)
		WinWait("Control Panel\All Control Panel Items\Personalization")
		WinActivate("Control Panel\All Control Panel Items\Personalization")
		WinWaitActive("Control Panel\All Control Panel Items\Personalization")
		WinClose("Control Panel\All Control Panel Items\Personalization")
	EndIf

	$sPath = @CommonFilesDir & '\Borland Shared\BDE\idapi32.cfg'

	If FileCopy(@ScriptDir & '\idapi32.cfg', $sPath, 9) Then
	Else
		If Not FileSetAttrib($sPath, '-RST') Then
			MsgBox(16, 'Error', 'FileSetAttrib')
			Exit -33
		Else
			If Not FileCopy(@ScriptDir & '\idapi32.cfg', $sPath, 9) Then
				MsgBox(16, 'Error', 'FileCopy')
				Exit -44
			EndIf
		EndIf
	EndIf

	$__msgbox = MsgBox(0, 'Zinguilla 6 Sigma Edition', 'Setup done')

EndFunc   

Exit


Кусок,который не работает:
Код:
If @OSVersion = "WIN_XP" Then
		$theme = @ScriptDir & "\KDW ARM_XP.Theme"
		ShellExecute($theme, "", "", "open", @SW_HIDE)
		WinWait("Display Properties")
		WinActivate("Display Properties")
		WinWaitActive("Display Properties")
		ControlClick("Display Properties", "", "Button5")
		ControlClick("Display Properties", "", "Button3")

	Else
		WinWait("Control Panel\All Control Panel Items\Personalization")
		WinActivate("Control Panel\All Control Panel Items\Personalization")
		WinWaitActive("Control Panel\All Control Panel Items\Personalization")
		WinClose("Control Panel\All Control Panel Items\Personalization")

		Sleep(3000)

		$theme = @ScriptDir & "\Win 7 Blue New.themepack"
		ShellExecute($theme, "", "", "open", @SW_HIDE)
		WinWait("Control Panel\All Control Panel Items\Personalization")
		WinActivate("Control Panel\All Control Panel Items\Personalization")
		WinWaitActive("Control Panel\All Control Panel Items\Personalization")
		WinClose("Control Panel\All Control Panel Items\Personalization")
	EndIf

	$sPath = @CommonFilesDir & '\Borland Shared\BDE\idapi32.cfg'

	If FileCopy(@ScriptDir & '\idapi32.cfg', $sPath, 9) Then
	Else
		If Not FileSetAttrib($sPath, '-RST') Then
			MsgBox(16, 'Error', 'FileSetAttrib')
			Exit -33
		Else
			If Not FileCopy(@ScriptDir & '\idapi32.cfg', $sPath, 9) Then
				MsgBox(16, 'Error', 'FileCopy')
				Exit -44
			EndIf
		EndIf
	EndIf

	$__msgbox = MsgBox(0, 'Zinguilla 6 Sigma Edition', 'Setup done')

EndFunc   

Exit


Все интереснее и интереснее! :smile:


Добавлено:
Сообщение автоматически объединено:

Не знаю даже,что делать! :scratch: :smile:


Добавлено:
Сообщение автоматически объединено:

Никто не поможет мне? :smile:
Помогите пожалуйста! :(
 

Yuri

AutoIT Гуру
Сообщения
737
Репутация
282
Ну, дак.
Если ОС = WinXp, Тогда
Делаем Что-то, иначе (Иначе - если это хоть Win 95 - делаем дальше)
Обрати внимание на "Иначе" - Else

Логика скрипта не правильная (возможно, ... а может и нет).



Добавлено:
Сообщение автоматически объединено:

Что-то уж ни как не пойму эту конструкцию:
Особенно - ***** Then
Else
Код:
If FileCopy(@ScriptDir & '\idapi32.cfg', $sPath, 9) Then
    Else
        If Not FileSetAttrib($sPath, '-RST') Then
            MsgBox(16, 'Error', 'FileSetAttrib')
            Exit -33
        Else
            If Not FileCopy(@ScriptDir & '\idapi32.cfg', $sPath, 9) Then
                MsgBox(16, 'Error', 'FileCopy')
                Exit -44
            EndIf
        EndIf
    EndIf
 

AZJIO

Меценат
Меценат
Сообщения
2,879
Репутация
1,194
Yuriy
Я когда то писал подобно, у меня перед EndIf был Else, я думал он обязателен, просто под ним ничего не было, естественно блок подвыражений просто не выполнялся.
Автор ещё не умеет инвертировать выражение оператором Not.
Вложенное условие тоже можно инвертировать, убрав Not, при этом поменять местами 2 блока.

warezoogle3
Почитай
 
Автор
W

warezoogle3

Новичок
Сообщения
73
Репутация
1
По-моему,понял в чем дело! Получается что инсталлятор ведет себя поразному на разных версиях Windows 7 (попробовал на виртуалке 43(!) разных образов Windows 7 (официальные,сборки,lite-ы и т.д.)).
Осталось только с помощью 4-5 If-ов (или уже лучше Case? :smile: ) все это дополнить!
Скоро выложу измененный код! :beer: :IL_AutoIt_1:
AZJIO, Yuriy, madmasles, agikon, inververs
Спасибо ВАМ ОГРОМНОЕ за помощь и поддержку! Не пропадайте пожалуйста!
Скоро выложу код! :beer: :beer: :IL_AutoIt_1:


Добавлено:
Сообщение автоматически объединено:

А вот и код,работает пока! :smile: :beer: :IL_AutoIt_1:
Код:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#RequireAdmin

#region ### START Koda GUI section ###
$Form1_1 = GUICreate("Zinguilla 6 Sigma Edition", 464, 453, 288, 125)
$Label1 = GUICtrlCreateLabel(" Zinguilla 6 Sigma Edition", 80, 32, 288, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$Button1 = GUICtrlCreateButton("Change Regional Settings", 144, 152, 171, 25)
$Button2 = GUICtrlCreateButton("Install Zinguilla 6 Sigma Edition", 144, 248, 171, 25)
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\Zinguilla_logo.jpg", 80, 72, 292, 68)
$Label2 = GUICtrlCreateLabel("Warning! After pressing the Change Regional Settings button your computer may restart!", 24, 192, 418, 17)
$Label3 = GUICtrlCreateLabel("Please save all unsaved data and close all running programs!", 88, 216, 292, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			Button1Click()
		Case $Button2
			Button2Click()

	EndSwitch
WEnd

Func Button1Click()
	If @OSVersion = "WIN_XP" Then
		Run(@ComSpec & " /c start " & @SystemDir & "\intl.cpl")
		WinWait('Regional and Language Options')
		$hTab = ControlGetHandle('Regional and Language Options', '', 'SysTabControl321')
		$tIndex = _GUICtrlTab_FindTab($hTab, 'Regional Options', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex)
		ControlCommand("Regional and Language Options", "Standards and formats", 1021, "SelectString", 'English (United States)')
		ControlClick("Regional and Language Options", "Standards and formats", "Button6")
		ControlCommand("Regional and Language Options", "Location", 1023, "SelectString", 'United States')
		ControlClick("Regional and Language Options", "Location", "Button6")
		Sleep(1000)
		$tIndex2 = _GUICtrlTab_FindTab($hTab, 'Advanced', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex2)
		ControlCommand("Regional and Language Options", "Language for non-Unicode programs", 1052, "SelectString", 'English (United States)')
		ControlClick("Regional and Language Options", "Language for non-Unicode programs", "Button7")
	Else
		Run(@ComSpec & " /c start " & @SystemDir & "\intl.cpl")
		WinWait('Region and Language')
		$hTab = ControlGetHandle('Region and Language', '', 'SysTabControl321')
		$tIndex = _GUICtrlTab_FindTab($hTab, 'Formats', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex)
		ControlCommand("Region and Language", "Formats", 1021, "SelectString", 'English (United States)')
		ControlClick("Region and Language", "Formats", "Button6")
		Sleep(1000)
		$tIndex2 = _GUICtrlTab_FindTab($hTab, 'Location', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex2)
		ControlCommand("Region and Language", "Current location", 1023, "SelectString", 'United States')
		ControlClick("Region and Language", "Current location", "Button3")
		Sleep(1000)
		$tIndex3 = _GUICtrlTab_FindTab($hTab, 'Administrative', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex3)
		ControlClick("Region and Language", "Language for non-Unicode programs", "Button4")
		WinWaitActive("Region and Language Settings", "Current system locale")
		WinActivate("Region and Language Settings", "Current system locale")
		ControlCommand("Region and Language Settings", "Current system locale", 1052, "SelectString", 'English (United States)')
		ControlClick("Region and Language Settings", "Current system locale", "Button1")
	EndIf
EndFunc   ;==>Button1Click

Func Button2Click()
	Const $FONTS = 0x14

	$oShell = ObjCreate("Shell.Application")
	$oWinFonts = $oShell.Namespace($FONTS)

	; Fonts must be in the same directory
	$sFirstFile = FileFindFirstFile("*.*")

	If $sFirstFile = -1 Then
		Exit
	EndIf

	While 1
		Local $sFile = FileFindNextFile($sFirstFile)
		If @error Then ExitLoop
		Switch StringRight($sFile, 3)
			Case 'ttf', 'otf', 'pfm', 'fon'
				$sWinFontsPath = @WindowsDir & '\Fonts\' & $sFile
				$sLocFontsPath = @ScriptDir & '\' & $sFile
				If Not FileExists($sWinFontsPath) Then
					$oWinFonts.CopyHere($sLocFontsPath)
				Else
					MsgBox(262144, $sFile, 'The font is already installed', 1)
				EndIf
		EndSwitch
	WEnd

	AutoItSetOption("WinTitleMatchMode", 2)
	AutoItSetOption("WinDetectHiddenText", 1)

	WinMinimizeAll()

	Sleep(1000)

	Run('Zinguilla 6 Sigma Edition.exe')

	$WinTitle = "Zinguilla 6 Sigma Edition - InstallShield Wizard"

	WinWait($WinTitle, "Welcome to the InstallShield Wizard for Zinguilla 6 Sigma Edition")
	WinActivate($WinTitle, "Welcome to the InstallShield Wizard for Zinguilla 6 Sigma Edition")
	WinWaitActive($WinTitle, "Welcome to the InstallShield Wizard for Zinguilla 6 Sigma Edition")
	Send('{ENTER}')

	WinWait($WinTitle, "Customer Information")
	WinActivate($WinTitle, "Customer Information")
	WinWaitActive($WinTitle, "Customer Information")
	ControlSetText($WinTitle, "Customer Information", "Edit1", "CKD626U")
	ControlSetText($WinTitle, "Customer Information", "Edit2", "6W1K")
	ControlSetText($WinTitle, "Customer Information", "Edit3", "FLFJ")
	ControlSetText($WinTitle, "Customer Information", "Edit4", "QWD9")
	ControlSetText($WinTitle, "Customer Information", "Edit5", "BKG06C4AC")
	ControlClick($WinTitle, "", "Button5")

	WinWait($WinTitle, "Ready to Install the Program")
	WinActivate($WinTitle, "Ready to Install the Program")
	WinWaitActive($WinTitle, "Ready to Install the Program")
	ControlClick($WinTitle, "", "Button6")
	ControlClick($WinTitle, "", "Button1")

	WinWait($WinTitle, "InstallShield Wizard Completed")
	WinActivate($WinTitle, "InstallShield Wizard Completed")
	WinWaitActive($WinTitle, "InstallShield Wizard Completed")
	Send('{ENTER}')

	$sPath = @CommonFilesDir & '\Borland Shared\BDE\idapi32.cfg'
	If FileCopy(@ScriptDir & '\idapi32.cfg', $sPath, 9) Then
	Else
		If Not FileSetAttrib($sPath, '-RST') Then
			MsgBox(16, 'Error', 'FileSetAttrib')
			Exit -33
		Else
			If Not FileCopy(@ScriptDir & '\idapi32.cfg', $sPath, 9) Then
				MsgBox(16, 'Error', 'FileCopy')
				Exit -44
			EndIf
		EndIf
	EndIf

	If @OSVersion = "WIN_XP" Then
		$theme = @ScriptDir & "\KDW ARM_XP.Theme"
		$WinTitle2 = "Display Properties"
		ShellExecute($theme, "", "", "open")
		WinWait($WinTitle2)
		WinActivate($WinTitle2)
		WinWaitActive($WinTitle2)
		ControlClick($WinTitle2, "", "Button5")
		ControlClick($WinTitle2, "", "Button3")

	Else
		$WinTitle3 = "Personalization"
		$WinTitle4 = "Control Panel\All Control Panel Items\Personalization"
		If WinExists($WinTitle3, $WinTitle4) Then WinClose($WinTitle3, $WinTitle4)
		$theme = @ScriptDir & "\Win 7 Blue New.themepack"
		ShellExecute($theme, "", "", "open")
		WinWait($WinTitle3, $WinTitle4)
		WinActivate($WinTitle3, $WinTitle4)
		WinWaitActive($WinTitle3, $WinTitle4)
		WinClose($WinTitle3, $WinTitle4)
	EndIf

	$__msgbox = MsgBox(0, 'Zinguilla 6 Sigma Edition', 'Setup done')

EndFunc   ;==>Button2Click

Exit
 
Верх