Jump to content

Get handle of active input control


 Share

Go to solution Solved by FireFox,

Recommended Posts

  • Solution

Hi,
Here you go:

#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
 
Global $_iInputFocused = -1
 
GUICreate("MyGUI")
 
Local $iInput1 = 0
For $i = 1 To 3
    $iInput1 = GUICtrlCreateInput("", 10, 10 + 25 * $i)
    GUICtrlSetData($iInput1, "My id: " & $iInput1)
Next
 
Local $iBtn1 = GUICtrlCreateButton("Which has focus?", 10, 150)
 
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState(@SW_SHOW)
 
While 1
    Sleep(10)
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $iBtn1
            MsgBox($MB_SYSTEMMODAL, "", "input id focused: " & $_iInputFocused)
    EndSwitch
WEnd
 
GUIDelete()
 
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $iCode = BitShift($iwParam, 16)
    Local $iIDFrom = BitAND($iwParam, 0x0000FFFF)
 
    Switch $iCode
        Case $EN_SETFOCUS
            $_iInputFocused = $iIDFrom
    EndSwitch
 
    Return $GUI_RUNDEFMSG
EndFunc
Br, FireFox.
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...