Jump to content

input boxes question


MirnesC2
 Share

Recommended Posts

For numbers you can use $ES_NUMBER, I'm not sure how to limit other stuff though.

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Link to comment
Share on other sites

I can't help but think there is a much easier way to do this, but here are two examples from one very tired person, but they should work.

#include <GUIConstantsEx.au3>
$GUI = GUICreate("GUI", 300, 70)
$Input1 = GUICtrlCreateInput("123Input123", 10, 10, 230, 20)
$Input2 = GUICtrlCreateInput("123Input123", 10, 40, 230, 20)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    AlphaOnly1($Input1, $GUI)
    AlphaOnly2($Input2, $GUI)
    Sleep(10)
WEnd


Func AlphaOnly1($ctrl, $fgui) ; Waits until the control no longer has focus
    $control = ControlGetFocus($fgui)
    If Not IsDeclared("focus") Then Global $focus = 0
    If ControlGetHandle($fgui, '', $control) = GUICtrlGetHandle($ctrl) Then
        $focus = 1
    EndIf
    If $focus = 1 And ControlGetHandle($fgui, '', $control) <> GUICtrlGetHandle($ctrl) Then
        $focus = 0
        $data = GUICtrlRead($ctrl)
        $reg = StringRegExp($data, '[[:alpha:] ]', 3)
        $ret = ''
        For $a = 0 To UBound($reg) - 1
            $ret &= $reg[$a]
        Next
        If $data <> $ret Then
            GUICtrlSetData($ctrl, $ret)
            Return 1
        EndIf
    EndIf
    Return 0
EndFunc   ;==>AlphaOnly

Func AlphaOnly2($ctrl, $fgui) ; Always checking. Will move cursor to end of string if it changes the data
    $data = GUICtrlRead($ctrl)
    $reg = StringRegExp($data, '[[:alpha:] ]', 3)
    $ret = ''
    For $a = 0 To UBound($reg) - 1
        $ret &= $reg[$a]
    Next
    If $data <> $ret Then
        GUICtrlSetData($ctrl, $ret)
        Return 1
    EndIf
    Return 0
EndFunc   ;==>AlphaOnly2
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...