Cocolas

[Solved]Detect inputbox focus

4 posts in this topic

#1 ·  Posted (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 by Cocolas

Share this post


Link to post
Share on other sites



#3 ·  Posted

$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

Share this post


Link to post
Share on other sites

#4 ·  Posted

Thank you Benners, it's exactly what I need and it work perfectly ^^

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now