Jump to content
Sign in to follow this  
totaln00ber

Input field listener

Recommended Posts

totaln00ber

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

Share this post


Link to post
Share on other sites
xcal

#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

Share this post


Link to post
Share on other sites
totaln00ber

Thanks, it works now; not sure what happened there, but I've got the logic down. : )

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  

×