Что нового

[Элементы GUI] Включение/Отключение/Запуск всех СheckBox-ов

TaskaM

Новичок
Сообщения
1
Репутация
0
Помогите допилить...
все что работает и не нужное удалил - по коду все и так будет понятно

Код:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>

Global $Profile[9] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
Global $Instance[9] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
Global $Launch[9] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
Global $ProfileSelect[9] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
Global $Emulator = "EMU"
Global $ManagerConfig = @ScriptDir & "\ManagerConfig.ini"

; ================================================== GUI PART ================================================== ;

GUICreate("Test", 540, 553, 192, 124)
GUISetIcon(@ScriptDir & "\images\Launcher.ico")

GUICtrlCreateGroup("", 5, 70, 530, 255)
$ProfileSelect[1] = GUICtrlCreateCheckbox ("", 11, 85, 15, 20)
$ProfileSelect[2] = GUICtrlCreateCheckbox ("", 11, 115, 15, 20)
$ProfileSelect[3] = GUICtrlCreateCheckbox ("", 11, 145, 15, 20)
$ProfileSelect[4] = GUICtrlCreateCheckbox ("", 11, 175, 15, 20)
$ProfileSelect[5] = GUICtrlCreateCheckbox ("", 11, 205, 15, 20)
$ProfileSelect[6] = GUICtrlCreateCheckbox ("", 11, 235, 15, 20)
$ProfileSelect[7] = GUICtrlCreateCheckbox ("", 11, 265, 15, 20)
$ProfileSelect[8] = GUICtrlCreateCheckbox ("", 11, 295, 15, 20)
$Instance[1] = GUICtrlCreateInput("Instance_1", 30, 85, 200, 20)
$Instance[2] = GUICtrlCreateInput("Instance_2", 30, 115, 200, 20)
$Instance[3] = GUICtrlCreateInput("Instance_3", 30, 145, 200, 20)
$Instance[4] = GUICtrlCreateInput("Instance_4", 30, 175, 200, 20)
$Instance[5] = GUICtrlCreateInput("Instance_5", 30, 205, 200, 20)
$Instance[6] = GUICtrlCreateInput("Instance_6", 30, 235, 200, 20)
$Instance[7] = GUICtrlCreateInput("Instance_7", 30, 265, 200, 20)
$Instance[8] = GUICtrlCreateInput("Instance_8", 30, 295, 200, 20)
$Profile[1] = GUICtrlCreateInput("Profile_1", 240, 85, 210, 20)
$Profile[2] = GUICtrlCreateInput("Profile_2", 240, 115, 210, 20)
$Profile[3] = GUICtrlCreateInput("Profile_3", 240, 145, 210, 20)
$Profile[4] = GUICtrlCreateInput("Profile_4", 240, 175, 210, 20)
$Profile[5] = GUICtrlCreateInput("Profile_5", 240, 205, 210, 20)
$Profile[6] = GUICtrlCreateInput("Profile_6", 240, 235, 210, 20)
$Profile[7] = GUICtrlCreateInput("Profile_7", 240, 265, 210, 20)
$Profile[8] = GUICtrlCreateInput("Profile_8", 240, 295, 210, 20)
$Launch[1] = GUICtrlCreateButton("Launch !", 460, 85, 70, 20)
$Launch[2] = GUICtrlCreateButton("Launch !", 460, 115, 70, 20)
$Launch[3] = GUICtrlCreateButton("Launch !", 460, 145, 70, 20)
$Launch[4] = GUICtrlCreateButton("Launch !", 460, 175, 71, 20)
$Launch[5] = GUICtrlCreateButton("Launch !", 460, 205, 70, 20)
$Launch[6] = GUICtrlCreateButton("Launch !", 460, 235, 70, 20)
$Launch[7] = GUICtrlCreateButton("Launch !", 460, 265, 70, 20)
$Launch[8] = GUICtrlCreateButton("Launch !", 460, 295, 70, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$SelAll = GUICtrlCreateButton ("Select All", 5, 330, 170, 25)
$SelNone = GUICtrlCreateButton ("Select None", 185, 330, 170, 25)
$SelRun = GUICtrlCreateButton ("Launch Selected", 365, 330, 170, 25)

;================================================================================
;$OpenMultiMEmu = GUICtrlCreateButton("Open Multi MEmu", 5, 380, 126, 26)
;$OpenMultiDroid4X = GUICtrlCreateButton("Open Multi Droid4X", 140, 380, 126, 26)
;$OpenMultiNox = GUICtrlCreateButton("Open Multi Nox", 275, 380, 126, 26)
;$OpenMultiLeapDroid = GUICtrlCreateButton("Open Multi LeapDroid", 410, 380, 126, 26)
;================================================================================

ReadnApplyConfig()

GUISetState(@SW_SHOW)

; ================================================== FUNCTIONS PART ================================================== ;

Func SaveConfig()
   IniWrite($ManagerConfig, "ProfileNames", "ProfileName[1]", GUICtrlRead($Profile[1]))
   IniWrite($ManagerConfig, "ProfileNames", "ProfileName[2]", GUICtrlRead($Profile[2]))
   IniWrite($ManagerConfig, "ProfileNames", "ProfileName[3]", GUICtrlRead($Profile[3]))
   IniWrite($ManagerConfig, "ProfileNames", "ProfileName[4]", GUICtrlRead($Profile[4]))
   IniWrite($ManagerConfig, "ProfileNames", "ProfileName[5]", GUICtrlRead($Profile[5]))
   IniWrite($ManagerConfig, "ProfileNames", "ProfileName[6]", GUICtrlRead($Profile[6]))
   IniWrite($ManagerConfig, "ProfileNames", "ProfileName[7]", GUICtrlRead($Profile[7]))
   IniWrite($ManagerConfig, "ProfileNames", "ProfileName[8]", GUICtrlRead($Profile[8]))
   IniWrite($ManagerConfig, "InstanceNames", "InstanceName[1]", GUICtrlRead($Instance[1]))
   IniWrite($ManagerConfig, "InstanceNames", "InstanceName[2]", GUICtrlRead($Instance[2]))
   IniWrite($ManagerConfig, "InstanceNames", "InstanceName[3]", GUICtrlRead($Instance[3]))
   IniWrite($ManagerConfig, "InstanceNames", "InstanceName[4]", GUICtrlRead($Instance[4]))
   IniWrite($ManagerConfig, "InstanceNames", "InstanceName[5]", GUICtrlRead($Instance[5]))
   IniWrite($ManagerConfig, "InstanceNames", "InstanceName[6]", GUICtrlRead($Instance[6]))
   IniWrite($ManagerConfig, "InstanceNames", "InstanceName[7]", GUICtrlRead($Instance[7]))
   IniWrite($ManagerConfig, "InstanceNames", "InstanceName[8]", GUICtrlRead($Instance[8]))
   If GUICtrlRead($ProfileSelect[1]) = $GUI_CHECKED Then
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[1]", 1)
	  Else
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[1]", 0)
   EndIf
   If GUICtrlRead($ProfileSelect[2]) = $GUI_CHECKED Then
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[2]", 1)
   Else
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[2]", 0)
   EndIf
   If GUICtrlRead($ProfileSelect[3]) = $GUI_CHECKED Then
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[3]", 1)
   Else
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[3]", 0)
   EndIf
   If GUICtrlRead($ProfileSelect[4]) = $GUI_CHECKED Then
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[4]", 1)
   Else
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[4]", 0)
   EndIf
   If GUICtrlRead($ProfileSelect[5]) = $GUI_CHECKED Then
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[5]", 1)
   Else
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[5]", 0)
   EndIf
   If GUICtrlRead($ProfileSelect[6]) = $GUI_CHECKED Then
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[6]", 1)
   Else
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[6]", 0)
   EndIf
   If GUICtrlRead($ProfileSelect[7]) = $GUI_CHECKED Then
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[7]", 1)
   Else
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[7]", 0)
   EndIf
   If GUICtrlRead($ProfileSelect[8]) = $GUI_CHECKED Then
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[8]", 1)
   Else
	  IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[8]", 0)
   EndIf
   EndFunc   ;==>SaveConfig

Func ReadnApplyConfig()
   GUICtrlSetData($Profile[1], IniRead($ManagerConfig, "ProfileNames", "Profile[1]", "Profile_1"))
   GUICtrlSetData($Profile[2], IniRead($ManagerConfig, "ProfileNames", "Profile[2]", "Profile_2"))
   GUICtrlSetData($Profile[3], IniRead($ManagerConfig, "ProfileNames", "Profile[3]", "Profile_3"))
   GUICtrlSetData($Profile[4], IniRead($ManagerConfig, "ProfileNames", "Profile[4]", "Profile_4"))
   GUICtrlSetData($Profile[5], IniRead($ManagerConfig, "ProfileNames", "Profile[5]", "Profile_5"))
   GUICtrlSetData($Profile[6], IniRead($ManagerConfig, "ProfileNames", "Profile[6]", "Profile_6"))
   GUICtrlSetData($Profile[7], IniRead($ManagerConfig, "ProfileNames", "Profile[7]", "Profile_7"))
   GUICtrlSetData($Profile[8], IniRead($ManagerConfig, "ProfileNames", "Profile[8]", "Profile_8"))
   GUICtrlSetData($Instance[1], IniRead($ManagerConfig, "InstanceNames", "Instance[1]", "Instance_1"))
   GUICtrlSetData($Instance[2], IniRead($ManagerConfig, "InstanceNames", "Instance[2]", "Instance_2"))
   GUICtrlSetData($Instance[3], IniRead($ManagerConfig, "InstanceNames", "Instance[3]", "Instance_3"))
   GUICtrlSetData($Instance[4], IniRead($ManagerConfig, "InstanceNames", "Instance[4]", "Instance_4"))
   GUICtrlSetData($Instance[5], IniRead($ManagerConfig, "InstanceNames", "Instance[5]", "Instance_5"))
   GUICtrlSetData($Instance[6], IniRead($ManagerConfig, "InstanceNames", "Instance[6]", "Instance_6"))
   GUICtrlSetData($Instance[7], IniRead($ManagerConfig, "InstanceNames", "Instance[7]", "Instance_7"))
   GUICtrlSetData($Instance[8], IniRead($ManagerConfig, "InstanceNames", "Instance[8]", "Instance_8"))
   $iSel1 = IniRead($ManagerConfig, "SelectedProfiles", "ProfileSelect[1]", "0")
   $iSel2 = IniRead($ManagerConfig, "SelectedProfiles", "ProfileSelect[2]", "0")
   $iSel3 = IniRead($ManagerConfig, "SelectedProfiles", "ProfileSelect[3]", "0")
   $iSel4 = IniRead($ManagerConfig, "SelectedProfiles", "ProfileSelect[4]", "0")
   $iSel5 = IniRead($ManagerConfig, "SelectedProfiles", "ProfileSelect[5]", "0")
   $iSel6 = IniRead($ManagerConfig, "SelectedProfiles", "ProfileSelect[6]", "0")
   $iSel7 = IniRead($ManagerConfig, "SelectedProfiles", "ProfileSelect[7]", "0")
   $iSel8 = IniRead($ManagerConfig, "SelectedProfiles", "ProfileSelect[8]", "0")
   If $iSel1 = 1 Then
	  GUICtrlSetState($ProfileSelect[1], $GUI_CHECKED)
   Else
	  GUICtrlSetState($ProfileSelect[1], $GUI_UNCHECKED)
   EndIf
   If $iSel2 = 1 Then
	  GUICtrlSetState($ProfileSelect[2], $GUI_CHECKED)
   Else
	  GUICtrlSetState($ProfileSelect[2], $GUI_UNCHECKED)
   EndIf
   If $iSel3 = 1 Then
	  GUICtrlSetState($ProfileSelect[3], $GUI_CHECKED)
   Else
	  GUICtrlSetState($ProfileSelect[3], $GUI_UNCHECKED)
   EndIf
   If $iSel4 = 1 Then
	  GUICtrlSetState($ProfileSelect[4], $GUI_CHECKED)
   Else
	  GUICtrlSetState($ProfileSelect[4], $GUI_UNCHECKED)
   EndIf
   If $iSel5 = 1 Then
	  GUICtrlSetState($ProfileSelect[5], $GUI_CHECKED)
   Else
	  GUICtrlSetState($ProfileSelect[5], $GUI_UNCHECKED)
   EndIf
   If $iSel6 = 1 Then
	  GUICtrlSetState($ProfileSelect[6], $GUI_CHECKED)
   Else
	  GUICtrlSetState($ProfileSelect[6], $GUI_UNCHECKED)
   EndIf
   If $iSel7 = 1 Then
	  GUICtrlSetState($ProfileSelect[7], $GUI_CHECKED)
   Else
	  GUICtrlSetState($ProfileSelect[7], $GUI_UNCHECKED)
   EndIf
   If $iSel8 = 1 Then
	  GUICtrlSetState($ProfileSelect[8], $GUI_CHECKED)
   Else
	  GUICtrlSetState($ProfileSelect[8], $GUI_UNCHECKED)
   EndIf
  EndFunc ;==>ReadnApplyConfig

Func SelectAll()
   GUICtrlSetState($ProfileSelect[1], $GUI_CHECKED)
   GUICtrlSetState($ProfileSelect[2], $GUI_CHECKED)
   GUICtrlSetState($ProfileSelect[3], $GUI_CHECKED)
   GUICtrlSetState($ProfileSelect[4], $GUI_CHECKED)
   GUICtrlSetState($ProfileSelect[5], $GUI_CHECKED)
   GUICtrlSetState($ProfileSelect[6], $GUI_CHECKED)
   GUICtrlSetState($ProfileSelect[7], $GUI_CHECKED)
   GUICtrlSetState($ProfileSelect[8], $GUI_CHECKED)
EndFunc

Func SelectNone()
   GUICtrlSetState($ProfileSelect[1], $GUI_UNCHECKED)
   GUICtrlSetState($ProfileSelect[2], $GUI_UNCHECKED)
   GUICtrlSetState($ProfileSelect[3], $GUI_UNCHECKED)
   GUICtrlSetState($ProfileSelect[4], $GUI_UNCHECKED)
   GUICtrlSetState($ProfileSelect[5], $GUI_UNCHECKED)
   GUICtrlSetState($ProfileSelect[6], $GUI_UNCHECKED)
   GUICtrlSetState($ProfileSelect[7], $GUI_UNCHECKED)
   GUICtrlSetState($ProfileSelect[8], $GUI_UNCHECKED)
EndFunc

Func RunSelected()
If GUICtrlRead($ProfileSelect[1]) = $GUI_CHECKED Then $Launch[1]
If GUICtrlRead($ProfileSelect[2]) = $GUI_CHECKED Then $Launch[2]
If GUICtrlRead($ProfileSelect[3]) = $GUI_CHECKED Then $Launch[3]
If GUICtrlRead($ProfileSelect[4]) = $GUI_CHECKED Then $Launch[4]
If GUICtrlRead($ProfileSelect[5]) = $GUI_CHECKED Then $Launch[5]
If GUICtrlRead($ProfileSelect[6]) = $GUI_CHECKED Then $Launch[6]
If GUICtrlRead($ProfileSelect[7]) = $GUI_CHECKED Then $Launch[7]
If GUICtrlRead($ProfileSelect[8]) = $GUI_CHECKED Then $Launch[8]
EndFunc


; ================================================== USER ACTIONS PART ================================================== ;

While 1
   Switch GUIGetMsg()
   Case $GUI_EVENT_CLOSE
	  SaveConfig()
	  ExitLoop
   Case $Launch[1]
	  ShellExecute(@ScriptDir & "\Bot.exe", """" & GUICtrlRead($Profile[1]) & """" & " " & $Emulator & " " & """" & GUICtrlRead($Instance[1]) & """")
   Case $Launch[2]
	  ShellExecute(@ScriptDir & "\Bot.exe", """" & GUICtrlRead($Profile[2]) & """" & " " & $Emulator & " " & """" & GUICtrlRead($Instance[2]) & """")
   Case $Launch[3]
	  ShellExecute(@ScriptDir & "\Bot.exe", """" & GUICtrlRead($Profile[3]) & """" & " " & $Emulator & " " & """" & GUICtrlRead($Instance[3]) & """")
   Case $Launch[4]
	  ShellExecute(@ScriptDir & "\Bot.exe", """" & GUICtrlRead($Profile[4]) & """" & " " & $Emulator & " " & """" & GUICtrlRead($Instance[4]) & """")
   Case $Launch[5]
	  ShellExecute(@ScriptDir & "\Bot.exe", """" & GUICtrlRead($Profile[5]) & """" & " " & $Emulator & " " & """" & GUICtrlRead($Instance[5]) & """")
   Case $Launch[6]
	  ShellExecute(@ScriptDir & "\Bot.exe", """" & GUICtrlRead($Profile[6]) & """" & " " & $Emulator & " " & """" & GUICtrlRead($Instance[6]) & """")
   Case $Launch[7]
	  ShellExecute(@ScriptDir & "\Bot.exe", """" & GUICtrlRead($Profile[7]) & """" & " " & $Emulator & " " & """" & GUICtrlRead($Instance[7]) & """")
   Case $Launch[8]
	  ShellExecute(@ScriptDir & "\Bot.exe", """" & GUICtrlRead($Profile[8]) & """" & " " & $Emulator & " " & """" & GUICtrlRead($Instance[8]) & """")
   Case $SelAll
	  SelectAll()
   Case $SelNone
	  SelectNone()
   Case $SelRun()
	  RunSelected()
   EndSwitch
WEnd
 
A

Alofa

Гость
Возможно вы такое имели ввиду:
Код:
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>

Global $SelAll, $SelNone, $SelRun
Global $Emulator = "EMU"
Global $aGlobalArray[8][4] ; Объединим $ProfileSelect[9], $Instance[9], $Profile[9] и $Launch[9] в один 2D массив
; А теперь посмотрите на сколько сократится код скрипта

GUICreate("Test", 540, 553, 192, 124)
GUISetIcon(@ScriptDir & "\images\Launcher.ico")

GUICtrlCreateGroup("", 5, 70, 530, 255)
For $i = 0 To 7 ; Создаем элементы в цикле
	$sTop = 85 + (30 * $i)
	$aGlobalArray[$i][0] = GUICtrlCreateCheckbox("", 11, $sTop, 15, 20) ; ..................... $ProfileSelect
	
	$aGlobalArray[$i][1] = GUICtrlCreateInput('', 30, $sTop, 200, 20) ; ... $Instance
	GUICtrlSendMsg(-1, $EM_SETCUEBANNER, 0, 'Instance_' & ($i + 1)) ; Надпись будет исчезать при клике на элементе (Можете убрать эту строку)
	
	$aGlobalArray[$i][2] = GUICtrlCreateInput('', 240, $sTop, 210, 20) ; ... $Profile
	GUICtrlSendMsg(-1, $EM_SETCUEBANNER, 0, 'Profile_' & ($i + 1)) ; Надпись будет исчезать при клике на элементе (Можете убрать эту строку)
	
	$aGlobalArray[$i][3] = GUICtrlCreateButton('Launch !' & ($i + 1), 460, $sTop, 70, 20) ; ... $Launch
Next
GUICtrlCreateGroup("", -99, -99, 1, 1)

$SelAll = GUICtrlCreateButton("Select All", 5, 330, 170, 25)
$SelNone = GUICtrlCreateButton("Select None", 185, 330, 170, 25)
$SelRun = GUICtrlCreateButton("Launch Selected", 365, 330, 170, 25)

;ReadnApplyConfig() ; Сейчас нам не до этого

GUISetState(@SW_SHOW)

While 1
	$iMsg = GUIGetMsg()
	Switch $iMsg
		Case $GUI_EVENT_CLOSE
			ExitLoop
		Case $SelAll
			_Selected($GUI_CHECKED)
		Case $SelNone
			_Selected($GUI_UNCHECKED)
		Case $SelRun
			RunSelected()
	EndSwitch
	
	RunSelected($iMsg)
WEnd


Func _Selected($iFlag)
	For $i = 0 To 7
		GUICtrlSetState($aGlobalArray[$i][0], $iFlag)
	Next
EndFunc   ;==>_Selected

Func RunSelected($iMsg = -1)
	For $i = 0 To 7
		If $iMsg = $aGlobalArray[$i][3] Or $iMsg = -1 Then
			If GUICtrlRead($aGlobalArray[$i][0]) = $GUI_CHECKED Then
				;ShellExecute(@ScriptDir & "\Bot.exe", """" & GUICtrlRead($Profile[1]) & """" & " " & $Emulator & " " & """" & GUICtrlRead($Instance[1]) & """")
				ConsoleWrite(@ScriptDir & '\Bot.exe "' & GUICtrlRead($aGlobalArray[$i][2]) & '" ' & $Emulator & ' "' & GUICtrlRead($aGlobalArray[$i][1]) & '"' & @LF)
			Else
				ConsoleWrite('!! $GUI_UNCHECKED !!' & @LF)
			EndIf
		EndIf
	Next
EndFunc   ;==>RunSelected



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

ИМХО: я бы убрал кнопки "Launch !..." вообще.
 

ra4o

AutoIT Гуру
Сообщения
1,165
Репутация
246
Вы ведь работаете с массивами , на проще ли сделать функции так :
Код:
Func SelectAll()
	For $i = 1 To UBound($ProfileSelect) - 1
		GUICtrlSetState($ProfileSelect[$i], $GUI_CHECKED)
	Next
EndFunc   ;==>SelectAll

Func SelectNone()
	For $i = 1 To UBound($ProfileSelect) - 1
		GUICtrlSetState($ProfileSelect[$i], $GUI_UNCHECKED)
	Next
EndFunc   ;==>SelectNone

Так-же поступить со всеми функциями.
Что Вы делаете в этой функции:
Код:
Func RunSelected()
If GUICtrlRead($ProfileSelect[1]) = $GUI_CHECKED Then $Launch[1]
If GUICtrlRead($ProfileSelect[2]) = $GUI_CHECKED Then $Launch[2]
If GUICtrlRead($ProfileSelect[3]) = $GUI_CHECKED Then $Launch[3]
If GUICtrlRead($ProfileSelect[4]) = $GUI_CHECKED Then $Launch[4]
If GUICtrlRead($ProfileSelect[5]) = $GUI_CHECKED Then $Launch[5]
If GUICtrlRead($ProfileSelect[6]) = $GUI_CHECKED Then $Launch[6]
If GUICtrlRead($ProfileSelect[7]) = $GUI_CHECKED Then $Launch[7]
If GUICtrlRead($ProfileSelect[8]) = $GUI_CHECKED Then $Launch[8]
EndFunc
Я так понимаю нажимаете на соответствующие кнопки? И как , работает ?

Вот, например, я не изменял логику скрипта, а только сократил код за счёт циклов и действие по кнопкам вынес в отдельную функцию "Launch()"
Код:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>

Global $Profile[9] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
Global $Instance[9] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
Global $Launch[9] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
Global $ProfileSelect[9] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
Global $Emulator = "EMU"
Global $ManagerConfig = @ScriptDir & "\ManagerConfig.ini"

; ================================================== GUI PART ================================================== ;

GUICreate("Test", 540, 553, 192, 124)
GUISetIcon(@ScriptDir & "\images\Launcher.ico")

GUICtrlCreateGroup("", 5, 70, 530, 255)
For $i = 1 To UBound($ProfileSelect) - 1
	$ProfileSelect[$i] = GUICtrlCreateCheckbox("", 11, 85 + ($i - 1) * 30, 15, 20)
	$Instance[$i] = GUICtrlCreateInput("Instance_" & $i, 30, 85 + ($i - 1) * 30, 200, 20)
	$Profile[$i] = GUICtrlCreateInput("Profile_" & $i, 240, 85 + ($i - 1) * 30, 210, 20)
	$Launch[$i] = GUICtrlCreateButton("Launch !", 460, 85 + ($i - 1) * 30, 70, 20)
Next


GUICtrlCreateGroup("", -99, -99, 1, 1)

$SelAll = GUICtrlCreateButton("Select All", 5, 330, 170, 25)
$SelNone = GUICtrlCreateButton("Select None", 185, 330, 170, 25)
$SelRun = GUICtrlCreateButton("Launch Selected", 365, 330, 170, 25)

;================================================================================
;$OpenMultiMEmu = GUICtrlCreateButton("Open Multi MEmu", 5, 380, 126, 26)
;$OpenMultiDroid4X = GUICtrlCreateButton("Open Multi Droid4X", 140, 380, 126, 26)
;$OpenMultiNox = GUICtrlCreateButton("Open Multi Nox", 275, 380, 126, 26)
;$OpenMultiLeapDroid = GUICtrlCreateButton("Open Multi LeapDroid", 410, 380, 126, 26)
;================================================================================

ReadnApplyConfig()

GUISetState(@SW_SHOW)

; ================================================== FUNCTIONS PART ================================================== ;

Func SaveConfig()
	For $i = 1 To UBound($Profile) - 1
		IniWrite($ManagerConfig, "ProfileNames", "ProfileName[" & $i & "]", GUICtrlRead($Profile[$i]))
		IniWrite($ManagerConfig, "InstanceNames", "InstanceName[" & $i & "]", GUICtrlRead($Instance[$i]))

		If GUICtrlRead($ProfileSelect[$i]) = $GUI_CHECKED Then
			IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[" & $i & "]", 1)
		Else
			IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[" & $i & "]", 0)
		EndIf
	Next

EndFunc   ;==>SaveConfig

Func ReadnApplyConfig()
	For $i = 1 To UBound($Profile) - 1
		GUICtrlSetData($Profile[$i], IniRead($ManagerConfig, "ProfileNames", "Profile[" & $i & "]", "Profile_" & $i))
		GUICtrlSetData($Instance[$i], IniRead($ManagerConfig, "InstanceNames", "Instance[" & $i & "]", "Instance_" & $i))
		$iSel = IniRead($ManagerConfig, "SelectedProfiles", "ProfileSelect[" & $i & "]", "0")
		If $iSel = 1 Then
			GUICtrlSetState($ProfileSelect[$i], $GUI_CHECKED)
		Else
			GUICtrlSetState($ProfileSelect[$i], $GUI_UNCHECKED)
		EndIf
	Next

EndFunc   ;==>ReadnApplyConfig

Func SelectAll()
	For $i = 1 To UBound($ProfileSelect) - 1
		GUICtrlSetState($ProfileSelect[$i], $GUI_CHECKED)
	Next
EndFunc   ;==>SelectAll

Func SelectNone()
	For $i = 1 To UBound($ProfileSelect) - 1
		GUICtrlSetState($ProfileSelect[$i], $GUI_UNCHECKED)
	Next
EndFunc   ;==>SelectNone


Func RunSelected()
	For $i = 1 To UBound($ProfileSelect) - 1
		If GUICtrlRead($ProfileSelect[$i]) = $GUI_CHECKED Then Launch($i)
	Next
EndFunc   ;==>RunSelected


Func Launch($Index)
	ShellExecute(@ScriptDir & "\Bot.exe", """" & GUICtrlRead($Profile[$Index]) & """" & " " & $Emulator & " " & """" & GUICtrlRead($Instance[$Index]) & """")
EndFunc   ;==>Launch


; ================================================== USER ACTIONS PART ================================================== ;

While 1
	Switch GUIGetMsg()
		Case $GUI_EVENT_CLOSE
			SaveConfig()
			ExitLoop
		Case $Launch[1]
			Launch(1)
		Case $Launch[2]
			Launch(2)
		Case $Launch[3]
			Launch(3)
		Case $Launch[4]
			Launch(4)
		Case $Launch[5]
			Launch(5)
		Case $Launch[6]
			Launch(6)
		Case $Launch[7]
			Launch(7)
		Case $Launch[8]
			Launch(8)
		Case $SelAll
			SelectAll()
		Case $SelNone
			SelectNone()
		Case $SelRun
			RunSelected()
	EndSwitch
WEnd
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
ra4o [?]
я не изменял логику скрипта, а только сократил код
Его можно сократить ещё:

Код:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>

Global $Profile[9] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
Global $Instance[9] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
Global $Launch[9] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
Global $ProfileSelect[9] = [0, 0, 0, 0, 0, 0, 0, 0, 0]
Global $Emulator = "EMU"
Global $ManagerConfig = @ScriptDir & "\ManagerConfig.ini"

; ================================================== GUI PART ================================================== ;

GUICreate("Test", 540, 553, 192, 124)
GUISetIcon(@ScriptDir & "\images\Launcher.ico")

GUICtrlCreateGroup("", 5, 70, 530, 255)

For $i = 1 To UBound($ProfileSelect) - 1
    $ProfileSelect[$i] = GUICtrlCreateCheckbox("", 11, 85 + ($i - 1) * 30, 15, 20)
    $Instance[$i] = GUICtrlCreateInput("Instance_" & $i, 30, 85 + ($i - 1) * 30, 200, 20)
    $Profile[$i] = GUICtrlCreateInput("Profile_" & $i, 240, 85 + ($i - 1) * 30, 210, 20)
    $Launch[$i] = GUICtrlCreateButton("Launch !", 460, 85 + ($i - 1) * 30, 70, 20)
Next

GUICtrlCreateGroup("", -99, -99, 1, 1)

$SelAll = GUICtrlCreateButton("Select All", 5, 330, 170, 25)
$SelNone = GUICtrlCreateButton("Select None", 185, 330, 170, 25)
$SelRun = GUICtrlCreateButton("Launch Selected", 365, 330, 170, 25)

;================================================================================
;$OpenMultiMEmu = GUICtrlCreateButton("Open Multi MEmu", 5, 380, 126, 26)
;$OpenMultiDroid4X = GUICtrlCreateButton("Open Multi Droid4X", 140, 380, 126, 26)
;$OpenMultiNox = GUICtrlCreateButton("Open Multi Nox", 275, 380, 126, 26)
;$OpenMultiLeapDroid = GUICtrlCreateButton("Open Multi LeapDroid", 410, 380, 126, 26)
;================================================================================

ReadnApplyConfig()
GUISetState(@SW_SHOW)

; ================================================== FUNCTIONS PART ================================================== ;

Func SaveConfig()
    For $i = 1 To UBound($Profile) - 1
        IniWrite($ManagerConfig, "ProfileNames", "ProfileName[" & $i & "]", GUICtrlRead($Profile[$i]))
        IniWrite($ManagerConfig, "InstanceNames", "InstanceName[" & $i & "]", GUICtrlRead($Instance[$i]))
		IniWrite($ManagerConfig, "SelectedProfiles", "ProfileSelect[" & $i & "]", Int(GUICtrlRead($ProfileSelect[$i]) = $GUI_CHECKED))
    Next
EndFunc   ;==>SaveConfig

Func ReadnApplyConfig()
    For $i = 1 To UBound($Profile) - 1
        GUICtrlSetData($Profile[$i], IniRead($ManagerConfig, "ProfileNames", "Profile[" & $i & "]", "Profile_" & $i))
        GUICtrlSetData($Instance[$i], IniRead($ManagerConfig, "InstanceNames", "Instance[" & $i & "]", "Instance_" & $i))
		GUICtrlSetState($ProfileSelect[$i], ((IniRead($ManagerConfig, "SelectedProfiles", "ProfileSelect[" & $i & "]", "0") = 1) ? $GUI_CHECKED : $GUI_UNCHECKED))
    Next
EndFunc   ;==>ReadnApplyConfig

Func SelectProc($bAll)
    For $i = 1 To UBound($ProfileSelect) - 1
        GUICtrlSetState($ProfileSelect[$i], $bAll ? $GUI_CHECKED : $GUI_UNCHECKED)
    Next
EndFunc   ;==>SelectAll

Func RunSelected()
    For $i = 1 To UBound($ProfileSelect) - 1
        If GUICtrlRead($ProfileSelect[$i]) = $GUI_CHECKED Then Launch($i)
    Next
EndFunc   ;==>RunSelected

Func Launch($Index)
    ShellExecute(@ScriptDir & "\Bot.exe", """" & GUICtrlRead($Profile[$Index]) & """" & " " & $Emulator & " " & """" & GUICtrlRead($Instance[$Index]) & """")
EndFunc   ;==>Launch

; ================================================== USER ACTIONS PART ================================================== ;

While 1
	$iMsg = GUIGetMsg()
	
    Switch $iMsg
		Case 0
			ContinueLoop
		Case $GUI_EVENT_CLOSE
            SaveConfig()
            ExitLoop
        Case $Launch[1] To $Launch[UBound($Launch) - 1]
			For $i = 1 To UBound($Launch) - 1
				If $iMsg = $Launch[$i] Then Launch($i)
			Next
        Case $SelAll, $SelNone
            SelectProc($iMsg = $SelAll)
        Case $SelRun
            RunSelected()
    EndSwitch
WEnd
 
Верх