Jump to content

[Solved]Detect inputbox focus


Recommended Posts

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
Link to comment
Share on other sites

$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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...