Что нового

Программа+Ключ+Ключ=Запуск программы с выбранными ключами

prokazzza

Новичок
Сообщения
160
Репутация
2
Еще раз приветствую гуру Autoita ! :smile: Собственно скрипт:

Код:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1_1 = GUICreate("Form1", 249, 118, 192, 114)

$Combo1 = GUICtrlCreateCombo("", 8, 48, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Key1|Key2", "Key1")

$Combo2 = GUICtrlCreateCombo("", 88, 48, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Key1|Key2", "Key1")

$Combo3 = GUICtrlCreateCombo("", 168, 48, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Key1|Key2", "Key1")

$Combo4 = GUICtrlCreateCombo("", 8, 16, 233, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Programm1|Programm2|Programm3", "Programm1")

$Button1 = GUICtrlCreateButton("Start", 8, 80, 97, 25)

GUISetState(@SW_SHOW)

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

		Case $Button1
			Run('')
	EndSwitch
WEnd


Подскажите как можно реализовать функцию выбора определенных ключей и программ из списка с последующим запуском программы с выбранными ключами.
 

Yuri

AutoIT Гуру
Сообщения
737
Репутация
282
Вот один из вариантов:
Код:
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
			$Program = GUICtrlRead($Combo4)
			$Key1 = GUICtrlRead($Combo1)
			$Key2 = GUICtrlRead($Combo2)
			$Key3 = GUICtrlRead($Combo3)			
			RunKey($Program, $Key1, $Key2, $Key3)            
    EndSwitch
WEnd

Func RunKey($Program, $Key1, $Key2, $Key3)	
	Switch $Program
		Case "Programm1"
			$Program = "tracert -h 3 -w 500"
			If $Key1 = "Key1" Then $Key = "ya.ru"
			If $Key1 = "Key2" Then $Key = "mail.ru"	
		Case "Programm2"
			$Program = "ipconfig"
			If $Key2 = "Key1" Then $Key = "/?"
			If $Key2 = "Key2" Then $Key = "/all"
		Case "Programm3"			
			$Program = "ping"
			If $Key3 = "Key1" Then $Key = "google.com"
			If $Key3 = "Key2" Then $Key = "yandex.ru"	
	EndSwitch	
	Run($Program&" "&$Key)
EndFunc
 
Автор
P

prokazzza

Новичок
Сообщения
160
Репутация
2
Спасибо!! :beer:

Вопрос, нельзя ли сделать так чтобы $Combo3 был недоступен/неактивен, пока не выберешь определенный ключ (к примеру Key2) из $Key1.

??
 

Yuri

AutoIT Гуру
Сообщения
737
Репутация
282
Можно. Примерно так:
Код:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1_1 = GUICreate("Form1", 249, 118, 192, 114)

$Combo1 = GUICtrlCreateCombo("", 8, 48, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Key1|Key2", "Key1")

$Combo2 = GUICtrlCreateCombo("", 88, 48, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Key1|Key2", "Key1")

$Combo3 = GUICtrlCreateCombo("", 168, 48, 73, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Key1|Key2", "Key1")
GUICtrlSetState($Combo3, $GUI_DISABLE);добавлено

$Combo4 = GUICtrlCreateCombo("", 8, 16, 233, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Programm1|Programm2|Programm3", "Programm1")

$Button1 = GUICtrlCreateButton("Start", 8, 80, 97, 25)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
		Case $Combo1;добавлено
			If GUICtrlRead($Combo1) = "Key2" Then ;добавлено
				GUICtrlSetState($Combo3, $GUI_ENABLE);добавлено
			Else;добавлено
				GUICtrlSetState($Combo3, $GUI_DISABLE);добавлено
			EndIf;добавлено			
        Case $Button1
			$Program = GUICtrlRead($Combo4)
			$Key1 = GUICtrlRead($Combo1)
			$Key2 = GUICtrlRead($Combo2)
			$Key3 = GUICtrlRead($Combo3)			
			RunKey($Program, $Key1, $Key2, $Key3)            
    EndSwitch
WEnd

Func RunKey($Program, $Key1, $Key2, $Key3)	
	Switch $Program
		Case "Programm1"
			$Program = "tracert -h 3 -w 500"
			If $Key1 = "Key1" Then $Key = "ya.ru"
			If $Key1 = "Key2" Then $Key = "mail.ru"	
		Case "Programm2"
			$Program = "ipconfig"
			If $Key2 = "Key1" Then $Key = "/?"
			If $Key2 = "Key2" Then $Key = "/all"
		Case "Programm3"			
			$Program = "ping"
			If $Key3 = "Key1" Then $Key = "google.com"
			If $Key3 = "Key2" Then $Key = "yandex.ru"	
	EndSwitch	
	Run($Program&" "&$Key)
EndFunc
 
Верх