Cotino Posted August 17, 2017 Share Posted August 17, 2017 (edited) Hi, The title is confusing, so here's what i want : When I click on the GUI window, outside of any control so just the window, remove focus on any control who has it. So if i click on an input and select the text, then click outside of the input, the input loses focus and doesnt select the text anymore. Is there a way to do that ? #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Global $GUImain = GUICreate("", 150, 50) GUISetOnEvent($GUI_EVENT_CLOSE, "EndGUI") Global $input = GUICtrlCreateInput("Something", 5, 5, 140, 20) GUISetState() While 1 Sleep(100) WEnd Func EndGUI() Exit EndFunc Edited August 17, 2017 by Cotino Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 17, 2017 Moderators Share Posted August 17, 2017 Cotino, Not too difficult: #include <GUIConstantsEx.au3> #include <GuiEdit.au3> Opt("GUIOnEventMode", 1) Global $GUImain = GUICreate("", 150, 50) GUISetOnEvent($GUI_EVENT_CLOSE, "EndGUI") GUISetOnEvent($GUI_EVENT_PRIMARYUP, "Click") Global $input = GUICtrlCreateInput("Something", 5, 5, 140, 20) GUISetState() While 1 Sleep(100) WEnd Func EndGUI() Exit EndFunc Func Click() ; Check which control in under the cursor $aInfo = GUIGetCursorInfo($GUImain) If $aInfo[4] <> $input Then ; If it is not the input then clear the input selection _GUICtrlEdit_SetSel($input, -1, -1) EndIf EndFunc 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...
Cotino Posted August 17, 2017 Author Share Posted August 17, 2017 Great answer as always Melba. Thanks ! Link to comment Share on other sites More sharing options...
Cotino Posted August 17, 2017 Author Share Posted August 17, 2017 (edited) Uhm, is there a way to not have to test if $aInfo[4] is different than every control ? I kinda have 67 controls on my current GUI and they are not in an array. Edited August 17, 2017 by Cotino Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 17, 2017 Moderators Share Posted August 17, 2017 Cotino, Try changing the condition to this: If $aInfo[4] = 0 Then Now it should work whenever you are not over any of your numerous controls - if you are then they should take focus anyway. 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...
Cotino Posted August 17, 2017 Author Share Posted August 17, 2017 Perfect. One last thing though, if i start clicking inside the input to select text, and release click outside of the input, it removes focus on the input. Any way to avoid that ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 18, 2017 Moderators Share Posted August 18, 2017 Cotino, Try changing GUISetOnEvent($GUI_EVENT_PRIMARYUP, "Click") to $GUI_EVENT_PRIMARYDOWN. 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...
Cotino Posted August 18, 2017 Author Share Posted August 18, 2017 Exactly what i was looking for. Thanks again. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 18, 2017 Moderators Share Posted August 18, 2017 Cotino, 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