Jump to content
Sign in to follow this  
gobsor

Update Label live with Input text?

Recommended Posts

gobsor

Hey its me again!

Got another problem, I'm pretty sure that's been asked before, but I couldn't find any example on how to do that, even though it got to be really easy!

I want a simple GUI with an Input and a Label on it, not a problem so far. But now I want the Label to read the text that is entered in the Input. So,

how do I update the Label with the Input's text? Gotta be some kind of while, I tried it like the following:

GUI/LABEL/INPUT CODE GOES HERE
[...]

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    GUICtrlSetData($streetlabel, GUICtrlRead($streetdate))
    GUICtrlSetData($riplabel, GUICtrlRead($ripdate))
    Sleep(200)
WEnd

This kinda works but is very, very unsexy. The Label field is fluttering and one definetly feels the 200ms delay sometimes when typing. Is there any better solution?

Regards

Share this post


Link to post
Share on other sites
PsaltyDS

You are constantly updating the label, even when it already contains the right data. Change your loop to check it first and only update if required.

If GuiCtrlRead($streetlabel) <> GuiCtrlRead($streetdate) Then GUICtrlSetData($streetlabel, GUICtrlRead($streetdate))

:blink:

Edited by PsaltyDS

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

Share this post


Link to post
Share on other sites
gobsor

Thanks a lot! I'm new to programming at all that's why I stuck at 'easy parts' pretty often, your solution is just perfect!

Regards

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.