eskeptic Posted July 1, 2010 Share Posted July 1, 2010 Hello!Ideally using GUIGetMsg(), I'd really like to distinguish between a user entering and leaving my input box (as it needs to be formatted when they tab or click away, but not when they enter it - otherwise the cursor is left at the wrong side of the text and they need to press shift+home before typing.)Does anyone know of a way to get more information about the event that GUIGetMsg is saying occurred at the input box?Thank you very much for the consideration!- GordonTeach Critical Thought Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 1, 2010 Moderators Share Posted July 1, 2010 eskeptic,Welcome to the AutoIt forum. There are no doubt sexier ways to do this by looking for the various messages that Windows would pass around, but this "hobbyist" version sems to work quite well: #include <GUIConstantsEx.au3> #include <WinAPI.au3> $fInput_Flag = False $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput("", 10, 10, 480, 20) $hInput_Handle = GUICtrlGetHandle($hInput) $hButton = GUICtrlCreateButton("Dummy", 10, 50, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If _WinAPI_GetFocus() = $hInput_Handle Then If $fInput_Flag = False Then $fInput_Flag = True Else If $fInput_Flag = True Then $fInput_Flag = False MsgBox(0, "Alert", "The user has left the input" & @CRLF & "You can now format the content") EndIf EndIf WEndWhat sort of formatting do you need to do to the input content? There might well be ways to do it on the fly. 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...
Mat Posted July 1, 2010 Share Posted July 1, 2010 Ah Melba... #include<WindowsConstants.au3> ; For $WM_COMMAND #include<WinApi.au3> ; For _WinApi_HiWord and LoWord #include<EditConstants.au3> ; for $EN_KILLFOCUS ; The variables are needed in functions too... Global $hEdit1, $hEdit2 GUICreate("This is a test", 400, 200) $hEdit1 = GUICtrlCreateInput("", 2, 2, 396, 20) $hEdit2 = GUICtrlCreateInput("", 2, 24, 396, 20) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; Register the message While GUIGetMsg() <> -3 ; Wait for close Sleep(10) WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) If _WinAPI_HiWord($iwParam) = $EN_KILLFOCUS Then ; An edit ctrl has lost focus Switch _WinAPI_LoWord($iwParam) Case $hEdit1 ConsoleWrite("Edit 1 has lost focus" & @CRLF) Case $hEdit2 ConsoleWrite("Edit 2 has lost focus" & @CRLF) EndSwitch EndIf EndFunc ;==>WM_COMMAND AutoIt Project Listing Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 1, 2010 Moderators Share Posted July 1, 2010 Mat, I did say there were sexier ways. 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...
Mat Posted July 1, 2010 Share Posted July 1, 2010 Mat,I did say there were sexier ways. M23I'm not sure messages are sexy... Or at least - sexy isn't the right word to describe them AutoIt Project Listing Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 1, 2010 Moderators Share Posted July 1, 2010 Mat,sexy isn't the right word to describe themMust be a generational thing... eskeptic,If you do go with Mat's code, please read the warning in the Help file on the GUIRegisterMsg page about returning quickly from the message handler. If your formatting takes any time at all, you may need to think of using a flag in the While...WEnd loop and doing it there. But we are getting ahead of ourselves a bit - as I mentioned earlier, what is this formatting? 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...
eskeptic Posted April 8, 2013 Author Share Posted April 8, 2013 Dear Melba & Mat. I sincerely apologise for taking so long to get back to you, I didn't get any notifications that my thread had been replied to! This project was put on hold until about a week ago and I'm still working out where I was up to with it. One of my comments was the URL to this thread. The formatting was to standardise the input of construction site addresses, which uses a large, slow validation routine, so thank you very much for the headsup about this. I might actually hold off on address standardisation until the user has dismissed the dialog after all. Thank you both very much for all of your hard work! Matt's beautiful solution won't go unused though, it will be useful to be able to trap these events to recalculate some values in another part of this project. - Gordon 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