Sign in to follow this  
Followers 0
talisin

Input - listen event onChange

4 posts in this topic

#1 ·  Posted (edited)

Hey there,

ive a problem with an input field.

If the user write something in the Input1 Field, the second one should be disabled.

The following code works fine but only if the user change the focus of the inputfield.

So is there any way how i could check if someone write into the field?

#include <GUIConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 371, 161, 242, 218)
$Input1 = GUICtrlCreateInput("", 40, 48, 273, 21)
$Input2 = GUICtrlCreateInput("", 40, 88, 121, 21)
$Input3 = GUICtrlCreateInput("", 192, 88, 121, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Input1
            If Guictrlread($Input1) <> "" Then
                GUICtrlSetState($Input2, $GUI_DISABLE)
            Else
                GUICtrlSetState($Input2, $GUI_ENABLE)
            EndIf
    EndSwitch
WEnd
Edited by talisin

Share this post


Link to post
Share on other sites



#include <GUIConstants.au3>
#include <editconstants.au3>
#include <windowsconstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 371, 161, 242, 218)
$Input1 = GUICtrlCreateInput("", 40, 48, 273, 21)
$Input2 = GUICtrlCreateInput("", 40, 88, 121, 21)
$Input3 = GUICtrlCreateInput("", 192, 88, 121, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_COMMAND, "My_WM_COMMAND");only used for EN_CHANGE so far
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Input1
            If GUICtrlRead($Input1) <> "" Then
                GUICtrlSetState($Input2, $GUI_DISABLE)
            Else
                GUICtrlSetState($Input2, $GUI_ENABLE)
            EndIf
    EndSwitch
WEnd

Func My_WM_COMMAND($hWnd, $imsg, $iwParam, $ilParam)
    Local $setHK = False
    $nNotifyCode = BitShift($iwParam, 16)
    $nID = BitAND($iwParam, 0x0000FFFF)
    $hCtrl = $ilParam
    
    If $nNotifyCode = $EN_CHANGE Then
        If $hCtrl = GUICtrlGetHandle($Input1) Then
            If GUICtrlRead($Input1) <> "" Then
                GUICtrlSetState($Input2, $GUI_DISABLE)
            Else
                GUICtrlSetState($Input2, $GUI_ENABLE)
            EndIf
            
        EndIf
        
    EndIf

    Return $GUI_RUNDEFMSG
    

EndFunc  ;==>My_WM_COMMAND


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

wow thanks, works great :P

Share this post


Link to post
Share on other sites

wow thanks, works great :P

That's good.

I didn't notice before, so it's a bit late, but welcome to the AutoIt forums :(


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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  
Followers 0