Cocolas Posted May 22, 2017 Share Posted May 22, 2017 (edited) Hello, I'm trying to detect if an inputbox got focus like this: $Enter_KEY = GUICtrlCreateDummy() Dim $Arr[1][2] = [["{ENTER}", $Enter_KEY]] GUISetAccelerators($Arr) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Enter_KEY if GUICtrlGetState($inp_ext)=80 Then GUICtrlSetState($inp_taille,$GUI_FOCUS) EndIf EndSwitch WEnd If we press enter and the caret cursor is in $inp_ext change focus to another inputbox. Changing focus work fine but I don't know how to define witch inputbox got the focus? Edited May 23, 2017 by Cocolas Link to comment Share on other sites More sharing options...
anthonyjr2 Posted May 22, 2017 Share Posted May 22, 2017 You want to be able to tell which input has the current focus? Use https://www.autoitscript.com/autoit3/docs/functions/ControlGetFocus.htm UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI= Link to comment Share on other sites More sharing options...
benners Posted May 22, 2017 Share Posted May 22, 2017 $Enter_KEY = GUICtrlCreateDummy() Dim $Arr[1][2] = [["{ENTER}", $Enter_KEY]] GUISetAccelerators($Arr) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Enter_KEY if _OIG_IsFocused($h_GUI, $inp_ext) Then GUICtrlSetState($inp_taille,$GUI_FOCUS) ;~ if GUICtrlGetState($inp_ext)=80 Then ;~ GUICtrlSetState($inp_taille,$GUI_FOCUS) EndIf EndSwitch WEnd Func _OIG_IsFocused($h_Wnd, $i_ControlID) ; Check if a control has focus. Return ControlGetHandle($h_Wnd, '', $i_ControlID) = ControlGetHandle($h_Wnd, '', ControlGetFocus($h_Wnd)) EndFunc ;==>_OIG_IsFocused Untested. $h_GUI should be the handle to your GUI matwachich and maniootek 2 Link to comment Share on other sites More sharing options...
Cocolas Posted May 23, 2017 Author Share Posted May 23, 2017 Thank you Benners, it's exactly what I need and it work perfectly ^^ 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