Jump to content

Is it possible to generate onFocus event on Input control


Recommended Posts

Currently, autoit generates event/message for an input control only after its content is changed (i.e. onchange event). Is it possible to have autoit generates an event/message whenever a user simply give focus to an input control (i.e. onfocus event) .

If you find out, please let me know. I just asked the same question yesterday here:

http://www.autoitscript.com/forum/index.php?showtopic=73371

Thanks

Link to comment
Share on other sites

Currently, autoit generates event/message for an input control only after its content is changed (i.e. onchange event). Is it possible to have autoit generates an event/message whenever a user simply give focus to an input control (i.e. onfocus event) .

See GUIRegisterMsg() in the helpfile.

Simple example: http://www.autoitscript.com/forum/index.ph...st&p=510428

Link to comment
Share on other sites

There were missing includes, so that wouldn't run.

This version seems to work (added some debug messages to the SciTE console so I could see what was up):

#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>

Global $hGUI = GUICreate("Test GUI", 300, 200)
$IdEdit1 = GUICtrlCreateEdit("Edit1", 10, 10, 280, 85)
ConsoleWrite("Debug: $IdEdit1 = " & $IdEdit1 & @LF)
$IdEdit2 = GUICtrlCreateEdit("Edit2", 10, 105, 280, 85)
ConsoleWrite("Debug: $IdEdit2 = " & $IdEdit2 & @LF)
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    ConsoleWrite("Debug: $wParam = " & $wParam & @LF)
    Local $wParamLow = BitAND($wParam, 0xFFFF)
    ConsoleWrite("Debug: $wParamLow = " & $wParamLow & @LF)
    Local $wParamHigh = BitShift($wParam, 16)
    ConsoleWrite("Debug: $wParamHigh = " & $wParamHigh & @LF)
   
    Switch $wParamLow
        Case $IdEdit1
            Switch $wParamHigh
                Case $EN_SETFOCUS
                    ConsoleWrite("Debug: Edit1 received focus!" & @LF)
            EndSwitch
    EndSwitch
EndFunc

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...