12321 Posted November 23, 2012 Share Posted November 23, 2012 (edited) I wanted to create a GUI where I can use ENTER on the keyboard. My first try was this one: expandcollapse popupOpt("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) #include<WindowsConstants.au3> #include<GUIConstantsEx.au3> #include<GuiButton.au3> #include<GuiEdit.au3> #include<EditConstants.au3> #include<WinAPI.au3> #include<Constants.au3> #include<StaticConstants.au3> Global $GUI _myGUI() While WinExists($GUI) Sleep(100) WEnd Func _myGUI() $GUI = GUICreate("myGUI", 510, 150, -1, -1, -1, $WS_EX_TOPMOST) GUISetOnEvent($GUI_EVENT_CLOSE, "_GUIclose") Global $myGUI_input = GUICtrlCreateInput("", 15, 75, 480, 20, $SS_CENTERIMAGE) _GUICtrlButton_Create($GUI, "Ok", 140, 110, 100, 25) GUICtrlSetOnEvent(-1, "_button_GUI_ok") GUICtrlCreateButton("Cancel", 270, 110, 100, 25) GUICtrlSetOnEvent(-1, "_GUIclose") GUISetState(@SW_SHOW) EndFunc ;==>_myGUI Func _button_GUI_ok() If WinExists(@GUI_WinHandle) Then Local $GUIposition = WinGetPos(@GUI_WinHandle) ToolTip("Poistion x = " & $GUIposition[0] & "and y = " & $GUIposition[1]) Else MsgBox(0,"","Why this MsgBox comes when I press ESC on the keyboard?") EndIf EndFunc ;==>_button_GUI_ok Func _GUIclose() GUIDelete(@GUI_WinHandle) EndFunc ;==>_GUIclose When I enter something in the input and click enter everything fine, but when (right after the creation of the GUI, without clicked enter or whatever) I enter some text in the input and click ESC on the keyboard then the function _button_GUI_ok() is called. Why??? Okay I already solved it: Instead of _GUICtrlButton_Create I can use GUICtrlCreateButton("Ok", 140, 110, 100, 25) and GUICtrlSetState(-1, $GUI_DEFBUTTON). I just was wondering that's kind of a bug in _GUICtrlButton_Create or??? Edited November 23, 2012 by 12321 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 23, 2012 Moderators Share Posted November 23, 2012 12321,You have the problem because you cannot create a control using the UDF function and then expect to action it using the GUICtrl* functions - they are used for controls created with AutoIt's native GUICtrlCreate* functions. As you can see from the example for _GUICtrlButton_Create, you need to look for the WM_COMMAND message to find out if the button was clicked. All clear? M23 12321 1 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...
12321 Posted November 23, 2012 Author Share Posted November 23, 2012 Ohhhh yes it is clear now! Maybe I should have had a closer look to the example before using it and confusing myself Thanks! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 23, 2012 Moderators Share Posted November 23, 2012 12321, Glad I could help. 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