Fadi Posted May 28, 2020 Share Posted May 28, 2020 (edited) Hi, I'm trying to create a GUI a multiple input, and set the inputs for each field in different variables, so i use then later into my Main function. This is what i'm trying to create. Any help where is my problem? expandcollapse popup#include <GUIConstants.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "quit") $GUI = GUICreate("Information", 280, 280) GUICtrlCreateLabel("Input1:", 10, 15, 65, 25) $TE_NumberInput= GUICtrlCreateInput("", 80, 10, 160, 25) GUICtrlCreateLabel("Input2:", 10, 55, 65, 25) $LocomotiveID_Input = GUICtrlCreateInput("", 80, 50, 160, 25) GUICtrlCreateLabel("Input3", 10, 95, 95, 25) $Direction_Input = GUICtrlCreateCombo("", 80, 90, 160, 25) GUICtrlSetData(-1, "Item1|item2|item3") GUICtrlCreateLabel("Input4", 10, 135, 65, 25) $EngineetPIN_Input = GUICtrlCreateInput("", 80, 130, 160, 25) $OK = GUICtrlCreateButton("OK", 30, 240, 60, 25) GUICtrlSetOnEvent($OK, "GetValue") $CANCEL = GUICtrlCreateButton("CANCEL", 110, 240, 60, 25) GUICtrlSetOnEvent($CANCEL, "quit") FUNC GetValue() GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $OK Global $Value1 = GUICtrlRead($Input1) Global $Value2 = GUICtrlRead($Input2) Global $Value3= GUICtrlRead($Input3) Global $Value4 = GUICtrlRead($Input4) exitloop EndSelect Wend EndFunc _Main() FUNC _Main() Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("Input1: " &$Input1 & "Input2: " &$Input2 & "Input3 :" &$Input3 &"Input4 :" $Input4) quit() EndFunc Func quit() Exit EndFunc Edited May 28, 2020 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 28, 2020 Moderators Share Posted May 28, 2020 Fadi, You are mixing OnEvent and MessageLoop modes - you cannot do this (well, not unless you are very careful). Just use OnEvent mode throughout - like this: expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "quit") Global $Value1, $Value2, $Value3, $Value4 $GUI = GUICreate("Information", 280, 280) GUISetOnEvent($GUI_EVENT_CLOSE, "quit") ; Here you set the [X] action GUICtrlCreateLabel("Input1:", 10, 15, 65, 25) $TE_NumberInput= GUICtrlCreateInput("", 80, 10, 160, 25) GUICtrlCreateLabel("Input2:", 10, 55, 65, 25) $LocomotiveID_Input = GUICtrlCreateInput("", 80, 50, 160, 25) GUICtrlCreateLabel("Input3", 10, 95, 95, 25) $Direction_Input = GUICtrlCreateCombo("", 80, 90, 160, 25) GUICtrlSetData(-1, "Item1|item2|item3") GUICtrlCreateLabel("Input4", 10, 135, 65, 25) $EngineetPIN_Input = GUICtrlCreateInput("", 80, 130, 160, 25) $OK = GUICtrlCreateButton("OK", 30, 240, 60, 25) GUICtrlSetOnEvent($OK, "GetValue") $CANCEL = GUICtrlCreateButton("CANCEL", 110, 240, 60, 25) GUICtrlSetOnEvent($CANCEL, "quit") GUISetState() ; Keep the script running While 1 Sleep(10) WEnd FUNC GetValue() ; Do not declare Global variables inside a function $Value1 = GUICtrlRead($TE_NumberInput) ; But do use the correct variable to denote the control to read $Value2 = GUICtrlRead($LocomotiveID_Input) $Value3= GUICtrlRead($Direction_Input) $Value4 = GUICtrlRead($EngineetPIN_Input) _Main() EndFunc FUNC _Main() ; This just writes to the SciTE console rather then Notepad ConsoleWrite("Input1: " & $Value1 & @CRLF & "Input2: " & $Value2 & @CRLF & "Input3 :" & $Value3 & @CRLF & "Input4 :" & $Value4 & @CRLF) quit() EndFunc Func quit() Exit EndFunc There are one or two other comments I have added to your code - please ask if you have any questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now