Что нового

Автоматическое закрытие скрипта после выбора

Hulk777

Новичок
Сообщения
69
Репутация
1
Здравствуйте. Имеется простенький скрипт.
Код:
#include <GUIConstants.au3>

FileInstall('Optimal.jpg', @TempDir & '\Optimal.jpg')

GUICreate('Установка Windows', 625, 400)
GUICtrlCreatePic(@TempDir & '\Optimal.jpg', 0, 0, 625, 400)
GUICtrlSetState(-1, $GUI_DISABLE)
$font = "Times new roman"
$Button1 = GUICtrlCreateButton('Windows 7 x 86 AIO Rus', 20, 20, 290, 80)
GUICtrlSetFont(-1, 16, 700, 0, $font) ; Жирный шрифт

$Button2 = GUICtrlCreateButton('Windows 8.1 x 86 AIO Rus', 20, 115, 290, 80)
GUICtrlSetFont(-1, 16, 700, 0, $font) ; Жирный шрифт

$Button3 = GUICtrlCreateButton('Windows 10 x 86 AIO Rus', 20, 210, 290, 80)
GUICtrlSetFont(-1, 16, 700, 0, $font) ; Жирный шрифт

$Button4 = GUICtrlCreateButton('Windows 7 x 64 AIO Rus', 320, 20, 290, 80)
GUICtrlSetFont(-1, 16, 700, 0, $font) ; Жирный шрифт

$Button5 = GUICtrlCreateButton('Windows 8.1 x 64 AIO Rus', 320, 115, 290, 80)
GUICtrlSetFont(-1, 16, 700, 0, $font) ; Жирный шрифт

$Button6 = GUICtrlCreateButton('Windows 10 x 64 AIO Rus', 320, 210, 290, 80)
GUICtrlSetFont(-1, 16, 700, 0, $font) ; Жирный шрифт

$Button7 = GUICtrlCreateButton('Windows XP x 86 Professional Rus', 20, 305, 590, 80)
GUICtrlSetFont(-1, 16, 700, 0, $font) ; Жирный шрифт
GUISetState()


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            FileDelete(@TempDir & '\Optimal.jpg')
            Exit
        Case $Button1
            Run(run ("X:\windows\scripts\set7.exe"))
	    Case $Button2
            Run(run ("X:\windows\scripts\set8.exe"))
	    Case $Button3
            Run(run ("X:\windows\scripts\set10.exe"))
	    Case $Button4
            Run(run ("X:\windows\scripts\set764.exe"))
	    Case $Button5
            Run(run ("X:\windows\scripts\set864.exe"))
	    Case $Button6
            Run(run ("X:\windows\scripts\set1064.exe"))
	    Case $Button7
            Run(run ("X:\windows\scripts\setXP.exe"))
    EndSwitch
WEnd

Что в него добавить чтобы он запускал exe и автоматически закрывался после нажатия любой из кнопок?
 

filautdinov

Знающий
Сообщения
96
Репутация
9
Exit после запуска


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

Код:
Run(run ("X:\windows\scripts\set7.exe"))
exit
 

inververs

AutoIT Гуру
Сообщения
2,135
Репутация
465
Код:
run ("X:\windows\scripts\set7.exe")
1 раза достаточно
 

---Zak---

Скриптер
Сообщения
455
Репутация
120
inververs
При условии, что там цикл - одно раза будет не достаточно :beer:
 
A

Alofa

Гость
Hulk777, а может лучше сделать так? :whistle:
Код:
FileInstall('Optimal.jpg', @TempDir & '\Optimal.jpg')

GUICreate('Установка Windows', 625, 400)
GUICtrlCreatePic(@TempDir & '\Optimal.jpg', 0, 0, 625, 400)
GUICtrlSetState(-1, $GUI_DISABLE)
$font = "Times new roman"
GUISetFont(16, 700, 0, $font) ; Жирный шрифт
$Button1 = GUICtrlCreateButton('Windows 7 x 86 AIO Rus', 20, 20, 290, 80)
$Button2 = GUICtrlCreateButton('Windows 8.1 x 86 AIO Rus', 20, 115, 290, 80)
$Button3 = GUICtrlCreateButton('Windows 10 x 86 AIO Rus', 20, 210, 290, 80)
$Button4 = GUICtrlCreateButton('Windows 7 x 64 AIO Rus', 320, 20, 290, 80)
$Button5 = GUICtrlCreateButton('Windows 8.1 x 64 AIO Rus', 320, 115, 290, 80)
$Button6 = GUICtrlCreateButton('Windows 10 x 64 AIO Rus', 320, 210, 290, 80)
$Button7 = GUICtrlCreateButton('Windows XP x 86 Professional Rus', 20, 305, 590, 80)
GUISetState()

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			FileDelete(@TempDir & '\Optimal.jpg')
			Exit
		Case $Button1 To $Button7
			_RunInstall($nMsg - $Button1)
	EndSwitch
WEnd

Func _RunInstall($i)
	Local $sOS[7] = ['Win7x86', 'Win8.1x86', 'Win10x86', 'Win7x64', 'Win8.1x64', 'Win10x64', 'WinXP']
	MsgBox(4096 + 64, $sOS[$i], 'Необязательно штамповать отдельный скрипт для каждой установки - все можно сделать в одном. К примеру вот в этой функции _RunInstall().')
EndFunc   ;==>_RunInstall
 

---Zak---

Скриптер
Сообщения
455
Репутация
120
inververs
OffTopic:
:rofl: не серчай - не заметил
 

Skif_off

Знающий
Сообщения
173
Репутация
12
Alofa
А почему
Код:
Case $Button1 To $Button7

? Значения $Button* всегда будут различаться на единицу? Иначе, так понимаю, в диапазон может влезть что-то ещё?
 
A

Alofa

Гость
Skif_off сказал(а):
... Иначе, так понимаю, в диапазон может влезть что-то ещё?
Правильно понимаете (и это радует).
При таком подходе, вы должны создавать кнопки одним общим блоком, по порядку.
Вы создатель GUI, здесь вы творите как вам захочеться.
 
Верх