Sign in to follow this  
Followers 0
Paulie

Detect Changes on Keypress

3 posts in this topic

#1 ·  Posted (edited)

Hey gang,

So I'm running into a problem. I'm trying to make a GUI with 5 Labels and 2 Inputboxes. 1 of the Inputs is Hidden. I want the user to enter a word, and then i want them to try to type the same word again, but I want the labels to reflect what they type except I want 1 character per label. It's hard to explain lol,

Here is a demo that explains my problem.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode",1)
Dim $Label[5]
$GUI = GUICreate("Form1", 400, 250, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
$Input = GUICtrlCreateInput("", 72, 192, 129, 21)
GUIctrlSetState(-1,$GUI_HIDE)
GUICtrlSetLimit(-1,5)
GUICtrlSetOnEvent(-1, "Compare")
For $x = 0 to 4
$Label[$x] = GUICtrlCreateLabel("", 72+40*$x, 136, 36, 17)
Next
$Compare = GUICtrlCreateInput("",200,200, 150,17)
GUICtrlSetLimit(-1,5)
GUICtrlSetOnEvent(-1, "Start")
GUISetState(@SW_SHOW)
While 1
    Sleep(100)
    ToolTip("Enter a 5-letter word in the box and push ENTER")
WEnd
Func Start()
    ToolTip("Now that the labels work, the GUI is unresponsive"&@CRLF&"Notice, you can't close the window"&@CRLF&"And Pressing ENTER doesnt trigger OnEvent")
    While 1
        ControlFocus($GUI,"", $Input)
        $Array = StringSplit(GuiCtrlRead($Input),"")
        For $x = 0 to $Array[0]-1
            IF GUICtrlRead($Label[$x]) <> $Array[$x+1] Then
                GUICtrlSetData($Label[$x], $Array[$x+1])
            EndIf
        Next
        For $x = 0 to 4
            If $x >= UBound($Array)-1 and GUICtrlRead($Label[$x]) <> "_" then
                GUICtrlSetData($Label[$x], "_")
            EndIf
        Next
    WEnd
EndFunc
Func Quit()
    Exit
EndFunc
Func Compare()
    MsgBox(0,"", "Comparing: " &@CRLF& GuiCtrlRead(@GUI_CtrlId) &@CRLF& GuiCtrlRead($Compare))
EndFunc

Any ideas on how to make this work correctly?

Edited by Paulie

Share this post


Link to post
Share on other sites



$HMOD = _WinAPI_GetModuleHandle(0)

$HHOOK = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($HSTUB_KEYPROC), $HMOD)


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

Thanks a bunch, I knew there was something I was forgetting about.

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