Rinfes
Новичок
- Сообщения
- 25
- Репутация
- 0
Здравствуйте. При совершении действий: нажатие кнопки "запуск новой генерации", далее нажатие кнопки или чекбокса, происходит ненужное выполнение кода(вызов функции или открытие окна сообщения), хотя обращение к участку кода не было.
p.s. обязательное условие, что новых GUI окон не должно появляться.
Чуть измененный код(убрано лишнее)
p.s. обязательное условие, что новых GUI окон не должно появляться.
Код:
#include <ListViewConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <MsgBoxConstants.au3>
Global $hGUI_main, $iButton_1, $iButton_2, $iButton_3, $iText
Global $iRand1Button, $iRand1CheckBox, $iRand1ComboBox, $iRand1DateTime, $iRand1Input ; переменные для элементов в задании на "3"
Global $sPath_ini = @ScriptDir & "\conf.ini"
$hGUI_main = GUICreate("AutoIt", 500, 400)
$iButton_1 = GUICtrlCreateButton("Запуск новой генерации", 125, 100, 250, 75)
$iButton_2 = GUICtrlCreateButton("Запуск последней генерации", 125, 250, 250, 75)
$iButton_3 = GuiCtrlCreateButton("Инфо", 460, 370)
$iText = GUICtrlCreateLabel("Случайная генерация элементов управления", 110, 20, 350)
GuiCtrlSetFont($iText, 14, 550)
ControlFocus("AutoIt","", $iButton_3)
GUISetState()
; главное меню
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $iButton_1
Generation() ; генерируем элементы
Case $iButton_2
MsgBox(0,"", "Нажата кнопка ""Запуск последней генерации""") ; восстанавливаем последнюю генерацию
Case $iButton_3
MsgBox(0, "", "Какая то информация")
EndSwitch
WEnd
Func Generation()
Local $iEl_1, $iEl_2
GUICtrlDelete($iButton_1)
GUICtrlDelete($iButton_2)
$iEl_1 = 0
$iEl_2 = 1
;~ $iEl_1 = Random(0, 4, 1)
;~ $iEl_2 = Random(0, 4, 1)
;~ If $iEl_1 = $iEl_2 Then
;~ $iEl_2 = Random(0, 4, 1)
;~ EndIf
IniWrite($sPath_ini, "load1", "1", $iEl_1)
IniWrite($sPath_ini, "load1", "2", $iEl_2)
Select ; Выполняет участок кода при истинности условия в Case.
Case ($iEl_1 = 0 And $iEl_2 = 1) Or ($iEl_1 = 1 And $iEl_2 = 0) ; button and checkbox
Gene1_1()
Case ($iEl_1 = 0 And $iEl_2 = 2) Or ($iEl_1 = 2 And $iEl_2 = 0) ; button and combobox
Gene1_2()
Case ($iEl_1 = 0 And $iEl_2 = 3) Or ($iEl_1 = 3 And $iEl_2 = 0) ; button and date/time
Gene1_3()
Case ($iEl_1 = 0 And $iEl_2 = 4) Or ($iEl_1 = 4 And $iEl_2 = 0) ; button and input
Gene1_4()
Case ($iEl_1 = 1 And $iEl_2 = 2) Or ($iEl_1 = 2 And $iEl_2 = 1) ; chekbox and combobox
Gene1_5()
Case ($iEl_1 = 1 And $iEl_2 = 3) Or ($iEl_1 = 3 And $iEl_2 = 1) ; checkbox and date/time
Gene1_6()
Case ($iEl_1 = 1 And $iEl_2 = 4) Or ($iEl_1 = 4 And $iEl_2 = 1) ; checkbox and input
Gene1_7()
Case ($iEl_1 = 2 And $iEl_2 = 3) Or ($iEl_1 = 3 And $iEl_2 = 2) ; combobox and date/time
Gene1_8()
Case ($iEl_1 = 2 And $iEl_2 = 4) Or ($iEl_1 = 4 And $iEl_2 = 2) ; combobox and input
Gene1_9()
Case ($iEl_1 = 3 And $iEl_2 = 4) Or ($iEl_1 = 4 And $iEl_2 = 3) ; date/time and input
Gene1_10()
EndSelect
EndFunc
Func Gene1_1()
$iRand1Button = GuiCtrlCreateButton("Button", 50, 100, 100, 50)
$iRand1CheckBox = GUICtrlCreateCheckbox("CheckBox", 200, 120, 120, 20)
EndFunc
Чуть измененный код(убрано лишнее)
Код:
#include <ListViewConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <MsgBoxConstants.au3>
Global $hGUI_main, $iButton_1, $iButton_2, $iButton_3, $iText
Global $iRand1Button, $iRand1CheckBox
$hGUI_main = GUICreate("AutoIt", 500, 400)
$iButton_1 = GUICtrlCreateButton("Запуск новой генерации", 125, 100, 250, 75)
$iButton_2 = GUICtrlCreateButton("Пока ненужная кнопка", 125, 250, 250, 75)
$iButton_3 = GuiCtrlCreateButton("Инфо", 460, 370)
$iText = GUICtrlCreateLabel("Случайная генерация элементов управления", 110, 20, 350)
GuiCtrlSetFont($iText, 14, 550)
ControlFocus("AutoIt","", $iButton_3)
GUISetState()
; главное меню
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $iButton_1
Generation() ; генерируем элементы
Case $iButton_2
MsgBox(0,"", "Нажата кнопка ""Пока ненужная кнопка""") ; восстанавливаем последнюю генерацию
Case $iButton_3
MsgBox(0, "", "Какая то информация")
EndSwitch
WEnd
Func Generation()
Local $iEl_1, $iEl_2
GUICtrlDelete($iButton_1)
GUICtrlDelete($iButton_2)
$iRand1Button = GuiCtrlCreateButton("Button", 50, 100, 100, 50)
$iRand1CheckBox = GUICtrlCreateCheckbox("CheckBox", 200, 120, 120, 20)
EndFunc