Jump to content

Does typing into an Input control raise an event?


Recommended Posts

Hello

Is there an event for the user typing into a GUICtrlCreateInput() control?

I tried registering an event for an Input control but it does not seem to fire when text is typed into it. The event does fire when the GUI is destroyed, though. Other button and GUI events are working OK.

Regards

Nick

Link to comment
Share on other sites

  • Moderators

Hello

Is there an event for the user typing into a GUICtrlCreateInput() control?

I tried registering an event for an Input control but it does not seem to fire when text is typed into it. The event does fire when the GUI is destroyed, though. Other button and GUI events are working OK.

Regards

Nick

In your loop you could check it like this:

If $Input1 <> "" Then
; whatever you want to do
EndIf
Link to comment
Share on other sites

In your loop you could check it like this:

If $Input1 <> "" Then
; whatever you want to do
EndIf

This doesn't work perfectly because in the case you want to enable a button for example you have continuous enables as long as you type in the text in the input form

Link to comment
Share on other sites

  • Moderators

This doesn't work perfectly because in the case you want to enable a button for example you have continuous enables as long as you type in the text in the input form

Something like this should work for that:

If Not $Input1 == "" And $Enabled Then
    GUICtrlSetState($Button1, $GUI_ENABLE)
    $Enabled = True
ElseIf $Enabled Then
    GUICtrlSetState($Button1, $GUI_DISABLE)
    $Enabled = False
EndIf
Link to comment
Share on other sites

Need Beta for the following:

#include <GuiConstants.au3>

Global Const $WM_COMMAND = 0x0111
Global Const $EN_CHANGE = 0x300
Global Const $DebugIt = 1

GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateInput("", 10, 5, 300, 20)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$input = GUICtrlCreateInput("", 10, 35, 300, 20)  ; will not accept drag&drop files
$btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20)

GUISetState()
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    Select
        Case $msg = $btn
            ExitLoop
    EndSelect
WEnd

Func _Input_Changed()
;----------------------------------------------------------------------------------------------
    If $DebugIt Then    ConsoleWrite (_DebugHeader("Input Changed:" & GUICtrlRead($input)))
;----------------------------------------------------------------------------------------------
EndFunc  ;==>_Input_Changed

Func _File_Changed()
;----------------------------------------------------------------------------------------------
    If $DebugIt Then    ConsoleWrite (_DebugHeader("File Changed:" & GUICtrlRead($file)))
;----------------------------------------------------------------------------------------------
EndFunc  ;==>_File_Changed

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam
    
    Switch $nID
        Case $input
            Switch $nNotifyCode
                Case $EN_CHANGE
                    _Input_Changed()
            EndSwitch
        Case $file
            Switch $nNotifyCode
                Case $EN_CHANGE
                    _File_Changed()
            EndSwitch
    EndSwitch
; Proceed the default Autoit3 internal message commands.
; You also can complete let the line out.
; !!! But only 'Return' (without any value) will not proceed
; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc  ;==>MY_WM_COMMAND

Func _DebugHeader($s_text)
    Return _
            "!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF
EndFunc  ;==>_DebugHeader

Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc  ;==>_HiWord

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc  ;==>_LoWord

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Thanks gafrost

This looks like exactly the answer, but my beta installation is not picking up beta\Include\GUIConstants.au3 although the beta 3.1.1 (beta) file is there (and does contain new constants such as $GUI_DROPACCEPTED).

Have I missed out some vital step in configuring the beta installation?

Best regards

Nick

Link to comment
Share on other sites

look at my sig, there's a link to the beta, believe the latest is 3.1.1.127

Edit: Also might want to look at useing SciTE (Alt+F5 runs the beta script, Alt+F7 compiles it)

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Thanks - I already had the beta, but Scite > Tools > SyntaxCheckBeta throws warnings about the new constants. It is reading the Include\ folder instead of beta\Include\. I guess this is the default for the #include keyword. My apologies for making a meal out of this - I'm sure when I fix this issue your solution above will work great.

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...