DigDeep Posted February 20, 2017 Posted February 20, 2017 Hi there, I wanted to click on $GetInput button to get the InputBox and $OK button displayed. (This works fine) But when clicking on clicking on $OK button, it does not do anything. basically, if there is nothing typed inside the InputBox then it should give the warning or else show what is typed in. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1, $GetInput, $Input, $OK Func Input() Global $TechAliasOutput = "C:\Temp\output.txt" $Input = GUICtrlCreateInput("", 245, 180, 170, 24) GUICtrlSetData($Input, "") $OK = GUICtrlCreateButton("OK", 350, 230, 75, 25, $SS_CENTER) GUICtrlSetState($OK, 512) Global $Input_Data = (GUICtrlRead($Input)) $aInfo = GUIGetCursorInfo($Form1) If $aInfo[2] Then If $aInfo[4] = $Input_Data Then GUICtrlSetData($Input_Data, "") EndIf Select Case $OK = $Input If $Input_Data = '' Then MsgBox(64, "", "InputBox is empty") Else MsgBox(0, '', GUICtrlRead($Input)) EndIf EndSelect EndFunc #Region $Form1 = GUICreate("Form1", 504, 283, -1, -1) $GetInput = GUICtrlCreateButton("Input", 200, 230, 75, 25, $SS_CENTER) GUISetState(@SW_SHOW) #EndRegion` While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GetInput Input() EndSwitch WEnd
Moderators Melba23 Posted February 20, 2017 Moderators Posted February 20, 2017 DigDeep, This seems to work for me: expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Global $Input, $OK = 9999 ; $OK must have a placeholder value or the case will fire on every pass Global $TechAliasOutput = "C:\Temp\output.txt" $Form1 = GUICreate("Form1", 504, 283, -1, -1) $GetInput = GUICtrlCreateButton("Input", 200, 230, 75, 25) ; Buttons are automatically centred - and use $BS_ styles in any event GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GetInput Input() Case $OK $Input_Data = GUICtrlRead($Input) ; So we read it here after the button is pressed If $Input_Data = '' Then MsgBox($MB_OK + $MB_ICONINFORMATION, "", "InputBox is empty") Else MsgBox($MB_OK, '', $Input_Data) EndIf GUICtrlDelete($Input) GUICtrlDelete($OK) $OK = 9999 ; Reset placeholder value EndSwitch WEnd Func Input() ;Global $TechAliasOutput = "C:\Temp\output.txt" ; Do not declare Global inside functions $Input = GUICtrlCreateInput("", 245, 180, 170, 24) ;GUICtrlSetData($Input, "") ; You have already set the input to empty when creatin git on the line above $OK = GUICtrlCreateButton("OK", 350, 230, 75, 25) GUICtrlSetState($OK, $GUI_DEFBUTTON) ; Why use magic numbers when you can use constants that explain what is going on? ;$Input_Data = (GUICtrlRead($Input)) ; if you read the input now there is nothing in it ; No idea what this is supposed to do ;$aInfo = GUIGetCursorInfo($Form1) ;If $aInfo[2] Then ; If $aInfo[4] = $Input_Data Then GUICtrlSetData($Input_Data, "") ;EndIf EndFunc 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
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