Jump to content
Sign in to follow this  
sandyd

Get handle of active input control

Recommended Posts

sandyd

Hi everyone,

Simple question but cant find an answer anywhere:

On a user created GUI, how can I determine the handle of the input control that's currently has focus?

TIA,

Sandy


----[ SandyD ]---

Share this post


Link to post
Share on other sites
FireFox

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.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
sandyd

Superb, Just what I needed.


----[ SandyD ]---

Share this post


Link to post
Share on other sites
FireFox

The best answer is to redirect people to what solved the topic, if you mark your post as the answer actually it's not.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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
Sign in to follow this  

×