Jump to content

Input field listener


Recommended Posts

Hello experts,

Trying to make an input field listener to see if there's any text type. If something is typed inside the input field, then a checkbox that's beside it should automatically be checked off. If the user presses backspace / clears the field, then the checkbox should uncheck itself. Here's what I have so far, but it doesn't seem to be working:

...
$chkCus = GUICtrlCreateCheckbox("", 225, 139, 17, 17)
$txtCus = GUICtrlCreateInput("", 245, 137, 82, 21)

$gCusTxt = GUICtrlRead($txtCus)

While 1
    If $gCusTxt <> "" Then
        GUICtrlSetState($chkCus, $GUI_CHECKED)
    Else
        GUICtrlSetState($chkCus, $GUI_UNCHECKED)
    EndIf
WEnd
Link to comment
Share on other sites

#include <GUIConstants.au3>

GUICreate('')

$checkbox = GUICtrlCreateCheckbox('some checkbox', 10, 10)

$input = GUICtrlCreateInput('', 10, 40)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If GUICtrlRead($input) <> '' Then
        GUICtrlSetState($checkbox, $GUI_CHECKED)
    Else
        GUICtrlSetState($checkbox, $GUI_UNCHECKED)
    EndIf
WEnd

Basically, you needed the guictrlread inside the loop.

Edited by xcal
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...