Jump to content

How to get events whilst typing in input box


Recommended Posts

Hi,

how can I get events whilst I type in an input box. I mean on every keyboard input. Currently I only get events when pressing "Tab" or clicking on another control after typing. What I want is to get events all the time during typing, input by input. Is that possible?

Here I have a sample. It is for like registering a new user with a new password. The password confirmation input should remain disabled until I type something in the password input field. And the OK button remains disabled until the typed confirmation password match the first password. Currently the input fields only send events after pressing "Tab" or clicking on another control. Help.

#include <GuiConstants.au3>
Opt("GUIOnEventMode", 1)

GuiCreate("Test Password", 200,140,(@DesktopWidth-200)/2, (@DesktopHeight-140)/2)

$label1 = GuiCtrlCreateLabel("Set &Name:", 10, 12, 55, 20)
$label1 = GuiCtrlCreateLabel("Set &Pass:", 10, 37, 55, 20)
$name  = GuiCtrlCreateInput("", 65, 10, 130, 20,)
$pass1 = GuiCtrlCreateInput("", 65, 35, 130, 20, $ES_PASSWORD)
$pass2 = GuiCtrlCreateInput("", 65, 60, 130, 20, $ES_PASSWORD)
$button_ok = GuiCtrlCreateButton("&OK", 15, 100, 80, 25)
$button_cancel = GuiCtrlCreateButton("&Cancel", 100, 100, 80, 25)

;======================================================================;

GuiCtrlSetState($pass2,$GUI_DISABLE)
GuiCtrlSetState($button_ok,$GUI_DISABLE)
GUICtrlSetOnEvent($pass1, "enable_pass2")
GUICtrlSetOnEvent($pass2, "enable_ok")
GUICtrlSetOnEvent($button_ok, "runme")
GUICtrlSetOnEvent($button_cancel, "quit")
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
GUISetState(@SW_SHOW)

Func enable_pass2()
    $str_pass1 = GUICtrlRead($pass1)
    If IsString($str_pass1) Then
        GuiCtrlSetState($pass2,$GUI_ENABLE)
    Else
        GuiCtrlSetState($pass2,$GUI_DISABLE)
    EndIf
EndFunc

Func enable_ok()
    $str_pass1 = GUICtrlRead($pass1)
    $str_pass2 = GUICtrlRead($pass2)
    If $str_pass2 = $str_pass1 Then
        GuiCtrlSetState($button_ok,$GUI_ENABLE)
    Else
        GuiCtrlSetState($button_ok,$GUI_DISABLE)
    EndIf
EndFunc

Func quit()
    Exit
EndFunc

Func runme()
    MsgBox(0,"Congratulations","Hello "&GUICtrlRead($name))
    Exit
EndFunc

;======================================================================;

While 1
    Sleep(1000)
WEnd
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...