Что нового

[Процессы] Подскажите как сократить цикл (т.е. составить его более компактно)

ivsatel

Продвинутый
Сообщения
319
Репутация
84
Здравствуйте.
Использую AutoIt версии 3.3.8.1
Написал цикл проверки, но мучает уверенность, что его же можно написать гораздо короче.
К примеру через
Код:
For

Вот цикл:
Код:
ProcExist()

Func PrcExist()
While 1
If ProcessExists('opera.exe')Then
	MsgBox('', '', 'Закройте браузер Opera и работа продолжиться.')
	ProcessWaitClose('opera.exe')
EndIf
If ProcessExists('firefox.exe') Then
	MsgBox('', '', 'Закройте браузер Firefox и работа продолжиться.')
	ProcessWaitClose('firefox.exe')
EndIf
If ProcessExists('chrome.exe') Then
	MsgBox('', '', 'Закройте браузер GoogleChrome и работа продолжиться.')
	ProcessWaitClose('chrome.exe')
EndIf
If ProcessExists('safari.exe') Then
	MsgBox('', '', 'Закройте браузер Safari и работа продолжиться.')
	ProcessWaitClose('safari.exe')
EndIf
If ProcessExists('palemoon.exe') Then
	MsgBox('', '', 'Закройте браузер Palemoon и работа продолжиться.')
	ProcessWaitClose('palemoon.exe')
EndIf
If ProcessExists('iexplore.exe') Then
	MsgBox('', '', 'Закройте браузер IExplore и работа продолжиться.')
	ProcessWaitClose('iexplore.exe')
EndIf
If ProcessExists('netscape.exe') Then
	MsgBox('', '', 'Закройте браузер Netscape и работа продолжиться.')
	ProcessWaitClose('netscape.exe')
EndIf
If ProcessExists('maxthon.exe') Then
	MsgBox('', '', 'Закройте браузер Maxthon и работа продолжиться.')
	ProcessWaitClose('maxthon.exe')
EndIf
If ProcessExists('thunderbird.exe') Then
	MsgBox('', '', 'Закройте Thunderbird и работа продолжиться.')
	ProcessWaitClose('thunderbird.exe')
EndIf
ExitLoop
WEnd
EndFunc
 

Yuri

AutoIT Гуру
Сообщения
737
Репутация
282
Пример
Код:
Dim $aProcName[5] = ["opera.exe", "firefox.exe", "chrome.exe", "notepad.exe", "calc.exe"]
ProcExist()
Func ProcExist()
For $i = 0 To 4
   If ProcessExists($aProcName[$i])Then
	  MsgBox('', '', 'Закройте ' & $aProcName[$i] & ' и работа продолжиться.')	
   EndIf
Next
EndFunc
 
Верх