Sign in to follow this  
Followers 0
JimC

GUICtrlCreateInput

5 posts in this topic

I am trying to figure out if this is possible. I am using a GUICTRLCreateInout, but I want to have input in the format of A-13-1 when the first character has to be uppercase A,B,C,D, or E then a "-", the a number ranging from 01 to 13 and then a "-" and finally a digit from 01 to 28. I have used the $ES_NUMBER so digits can be type, but I would like to control the input as explained above. Is that possible and how can it be done ? Any assistance would be greatly appreciated.

Share this post


Link to post
Share on other sites



Use a function that reads when the edit control is edited... This is just an example, you will need to expand on the parser function :D

#include<WindowsConstants.au3>

$hGUI = GUICreate ("Testing my control!", 300, 200, -1, -1)
Global $hInput = GUICtrlCreateInput ("", 2, 2, 80, 20)

GUIRegisterMsg ($WM_COMMAND, "WM_COMMAND")
GUISetstate ()

While GUIGetMsg () <> -3
WEnd

Func WM_COMMAND ($hWnd, $msgID, $l, $r)
   If $l = 0x04000003 Then ; text changed
      $txt = GUICtrlRead ($hInput)
      $txt = StringLen ($txt)
      If $txt > 10 Then GUICtrlSetData ($hInput, "I am silly")
      GUICtrlSetData ($hInput, StringLeft ("I am silly", $txt), "")
   EndIf
EndFunc ; ==> WM_COMMAND

Lol :D

Mat

Share this post


Link to post
Share on other sites

I think this parsing should work, like u need.

#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GuiConstants.au3>

$gui = GUICreate('test')
$input = GUICtrlCreateInput('', 20, 20, 150, 20)
GUISetState()

GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')

Do
Until GUIGetMsg() = -3

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndInput, $str
    If Not IsHWnd($input) Then $hWndInput = GUICtrlGetHandle($input)
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF)
    $iCode = BitShift($iwParam, 16)
    If $hWndFrom = $hWndInput Then
        $str = GUICtrlRead($input)
        Switch $iCode
            Case $EN_CHANGE
                Switch StringLen($str)
                    Case 1
                        If Not StringRegExp($str, '[A-E]') Then
                            GUICtrlSetData($input, '')
                        Else
                            GUICtrlSetData($input, $str & '-')
                        EndIf
                    Case 3
                        If Not StringRegExp($str, '[A-E]-[01]') Then
                            GUICtrlSetData($input, StringTrimRight($str, 1))
                        EndIf
                    Case 4
                        If Not StringRegExp($str, '[A-E]-(0[1-9]|1[0-3])') Then
                            GUICtrlSetData($input, StringTrimRight($str, 1))
                        Else
                            GUICtrlSetData($input, $str & '-')
                        EndIf
                    Case 6
                        If Not StringRegExp($str, '[A-E]-(0[1-9]|1[0-3])-[012]') Then
                            GUICtrlSetData($input, StringTrimRight($str, 1))
                        EndIf
                    Case 7
                        If Not StringRegExp($str, '[A-E]-(0[1-9]|1[0-3])-(0[1-9]|1[0-9]|2[0-8])') Then
                            GUICtrlSetData($input, StringTrimRight($str, 1))
                        EndIf
                    Case 8
                        GUICtrlSetData($input, StringTrimRight($str, 1))
                EndSwitch
        EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Best Regards BugFix  

Share this post


Link to post
Share on other sites

Another way.

#Include <EditConstants.au3>
#Include <GUIConstantsEx.au3>
#Include <StaticConstants.au3>
#Include <WindowsConstants.au3>
#Include <WinAPI.au3>

GUICreate('MyGUI', 106, 30)
$Input1 = GUICtrlCreateInput('', 5, 5, 24, 17, $ES_CENTER)
GUICtrlCreateLabel('-', 30, 6, 10, 15, $SS_CENTER )
$Input2 = GUICtrlCreateInput('', 41, 5, 24, 17, $ES_CENTER)
GUICtrlCreateLabel('-', 66, 6, 10, 15, $SS_CENTER )
$Input3 = GUICtrlCreateInput('', 77, 5, 24, 17, $ES_CENTER)
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState()

Do
Until GUIGetMsg() = -3

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    Local $From = BitAND($wParam, 0xFFFF)
    Local $Code = BitShift($wParam, 16)
    Local $Data

    Switch $Code
        Case $EN_CHANGE
            Switch $From
                Case $Input1
                    $Data = StringLeft(StringRegExpReplace(StringUpper(GUICtrlRead($From)), '[^A-E]', ''), 1)
                    If $Data Then
                        _WinAPI_SetFocus(GUICtrlGetHandle($Input2))
                    EndIf
                Case $Input2, $Input3
                    $Data = StringLeft(StringRegExpReplace(GUICtrlRead($From), '[^\d]', ''), 2)
                    If (StringLen($Data) = 2) And ($From = $Input2) Then
                        _WinAPI_SetFocus(GUICtrlGetHandle($Input3))
                    EndIf
                Case Else
                    Return $GUI_RUNDEFMSG
            EndSwitch
            GUICtrlSetData($From, $Data)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Share this post


Link to post
Share on other sites

It would seem that I never get out of the last input box prior to Button3 getting activated. I need the second value for $cube2 to be either 1,2,3,4,5,6,7,8,9,10,11,12, or 13. I also need to use the value of that function to be returned so I can use it to manipulate something later. Is the little stipet legal ? I also need to know why I never get out of the Func WM_Command

$pcube = GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')

do

until GUIGetMsg() =-3

GUICtrlSetState($Button3, $gui_enable)

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <array.au3>
#include <file.au3>
#include <WindowsConstants.au3>
#Include <StaticConstants.au3>
#Include <WinAPI.au3>

Global $computer, $costcenter, $pcomputer, $amosrce, $pcostcenter, $pprimuser, $floor1, $pcube


#Region ### START Koda GUI section ### Form=C:\Documents and Settings\e15850t\Desktop\Form1.kxf
$Form1 = GUICreate("AMO Mif Fix", 630, 500, 379, 121)
$Group1 = GUICtrlCreateGroup("Pc Information", 8, 16, 217, 129)
$computer = GUICtrlCreateInput("", 20, 64, 105, 30, $ES_LOWERCASE)
GUICtrlSetState(-1, $GUI_FOCUS)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Ping", 144, 64, 75, 33, 0)
$Label1 = GUICtrlCreateLabel("PC Name", 56, 40, 49, 17)
;GUICtrlCreateGroup("", -99, -99, 1, 1)


$Group2 = GUICtrlCreateGroup("User Information for PC", 8, 152, 260, 330)
$Label2 = GUICtrlCreateLabel("Cost Center", 12, 184, 59, 17)
$costcenter = GUICtrlCreateInput("", 10, 208, 75, 28, $ES_NUMBER)
GUICtrlSetLimit(-1, 5)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetState($costcenter, $gui_disable)
$Label3 = GUICtrlCreateLabel("Primary User", 12, 248, 63, 17)
$primeuser = GUICtrlCreateInput("", 8.5, 272, 230, 28, $ES_UPPERCASE)
GUICtrlSetLimit(-1, 25, 7)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetState($primeuser, $gui_disable)
$Label4 = GUICtrlCreateLabel("Floor:  Valid value 1,2,4", 12, 308, 120, 17)
;$Combo1 = GUICtrlCreateCombo("", 10, 328, 200, 25)
;GUICtrlSetData(-1, "1|2", "1"); add other item snd set a new default
$floor = GUICtrlCreateInput("", 10, 328, 200, 25, $ES_NUMBER)
GUICtrlSetState($floor, $gui_disable)
GUICtrlSetLimit(-1, 1)
$Label5 = GUICtrlCreateLabel("Cube location:  Format: A-13-1", 12, 358, 160, 17)

$cube1 = GUICtrlCreateInput('', 10, 380, 30, 25, $ES_CENTER)
GUICtrlCreateLabel('-',42, 380, 10,15, $SS_CENTER)
$cube2 = GUICtrlCreateInput('', 50, 380, 30, 25, $ES_CENTER)
GUICtrlCreateLabel('-',80, 380, 10,15, $SS_CENTER)
$cube3 = GUICtrlCreateInput('', 90, 380, 30, 25, $ES_CENTER)
GUICtrlSetState($cube1, $gui_disable)
GUICtrlSetState($cube2, $gui_disable)
GUICtrlSetState($cube3, $gui_disable)

$Button3 = GUICtrlCreateButton("Modify Mif", 24, 435, 99, 33, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetState($Button3, $gui_disable)
$Group3 = GUICtrlCreateGroup("PC Alive ?", 280, 24, 313, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Drive Mapped ?", 277, 127, 313, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Group5 = GUICtrlCreateGroup("Mif Current", 282, 190, 313, 125)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label6 = GUICtrlCreateLabel("Cost Center: ", 285, 210, 63, 17)
$Label7 = GUICtrlCreateLabel("Primary User: ", 285, 230, 63, 17)
$Label8 = GUICtrlCreateLabel("Floor: ", 285, 250, 63, 17)
$Label9 = GUICtrlCreateLabel("Building: ", 285, 270, 63, 17)
$label14 = GUICtrlCreateLabel("Cube location: ", 285, 290, 90, 17)

$Group6 = GUICtrlCreateGroup("Mif Written", 282, 330, 313, 130)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label10 = GUICtrlCreateLabel("Cost Center: ", 285, 350, 63, 17)
$Label11 = GUICtrlCreateLabel("Primary User: ", 285, 370, 63, 17)
$Label12 = GUICtrlCreateLabel("Floor: ", 285, 390, 63, 17)
$Label13 = GUICtrlCreateLabel("Building: ", 285, 410, 63, 17)
$label14 = GUICtrlCreateLabel("Cube location: ", 285, 430, 90, 17)


GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$message = GUICtrlCreateLabel('                           ', 300, 50, 570, 20)
$message1 = GUICtrlCreateLabel('                           ', 300, 50, 570, 20)
$message2 = GUICtrlCreateLabel('                         ', 300, 50, 570, 20)
$message3 = GUICtrlCreateLabel('                         ', 300, 50, 570, 20)
$message4 = GUICtrlCreateLabel('                         ', 310, 140, 570, 20)
$message5 = GUICtrlCreateLabel('                         ', 310, 140, 570, 20)
$message6 = GUICtrlCreateLabel('                         ', 350, 210, 570, 20)
$message7 = GUICtrlCreateLabel('                         ', 350, 350, 570, 20)
$message8 = GUICtrlCreateLabel('                         ', 350, 230, 570, 20)
$message9 = GUICtrlCreateLabel('                         ', 350, 370, 570, 20)
$message10 = GUICtrlCreateLabel('                         ', 350, 250, 570, 20)
$message11 = GUICtrlCreateLabel('                         ', 350, 390, 570, 20)
$message12 = GUICtrlCreateLabel('                         ', 350, 270, 570, 20)
$message13 = GUICtrlCreateLabel('                         ', 350, 410, 570, 20)
$message14 = GUICtrlCreateLabel('                         ', 350, 290, 570, 20)
$message15 = GUICtrlCreateLabel('                         ', 350, 430, 570, 20)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            MyPing()
        Case $Button3
            Modmif()

    EndSwitch
WEnd

Func MyPing()
    GUICtrlDelete($message2)
    GUICtrlDelete($message3)
    GUICtrlDelete($message4)
    GUICtrlDelete($message5)
    If GUICtrlRead($computer) = '' Then
        $message = GUICtrlCreateLabel('PC name is blank !', 300, 50, 570, 20)
        Sleep(3000)
        GUICtrlDelete($message)
        Return
    Else
        $pcomputer = GUICtrlRead($computer)
        $message1 = GUICtrlCreateLabel('Pinging PC:   ' & $pcomputer, 300, 50, 570, 20)
        Sleep(3000)
        GUICtrlDelete($message1)

    EndIf
    $var = Ping($pcomputer, 250)
    If $var <> 0 Then

        $message2 = GUICtrlCreateLabel(GUICtrlRead($computer) & ' is online !', 300, 50, 570, 20)
        GUICtrlSetState($Button1, $gui_disable)
        MapDrive()
    Else
        $message3 = GUICtrlCreateLabel(GUICtrlRead($computer) & ' is offline !', 300, 50, 570, 20)
        GUICtrlSetData($computer, "")
        GUICtrlSetState($computer, $GUI_FOCUS)
    EndIf
EndFunc   ;==>MyPing

Func MapDrive()
    $amosrce = DriveMapAdd("*", "\\" & $pcomputer & "\c$\uam4\clientws", 8)
    If Not @error Then
        ;msgbox(0,"AmoFix!!!","The drive was mapped as " &$amosrce,2)
        $message4 = GUICtrlCreateLabel('Drive mapped as ' & $amosrce, 310, 140, 570, 20)
        GUICtrlSetState($costcenter, $gui_enable)
        GUICtrlSetState($costcenter, $GUI_FOCUS)
        GUICtrlSetState($primeuser, $gui_disable)
        GUICtrlSetState($floor, $gui_disable)
        GUICtrlSetState($computer, $gui_disable)
        
        userinfo()
    Else
        $message5 = GUICtrlCreateLabel('The drive was not mapped !!!', 310, 140, 570, 20)
        GUICtrlSetState($Button1, $gui_enable)
        Return
    EndIf
EndFunc   ;==>MapDrive

Func userinfo()

    While $pcostcenter < 10000
        $pcostcenter = GUICtrlRead($costcenter)
    WEnd
    GUICtrlSetState($costcenter, $gui_disable)
    GUICtrlSetState($primeuser, $gui_enable)
    GUICtrlSetState($primeuser, $GUI_FOCUS)
    GUICtrlSetState($floor, $gui_enable)
    
    While Not ($floor1 = 1 Or $floor1 = 2 or $floor1=4)
        $floor1 = GUICtrlRead($floor)
    WEnd
    
    GUICTRLSetState($cube1, $gui_enable)
    GUICTRLSetState($cube2, $gui_enable)
    GUICTRLSetState($cube3, $gui_enable)
    
    $pcube = GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
    do 
    until GUIGetMsg() =-3
    
    GUICtrlSetState($Button3, $gui_enable)
    
EndFunc   ;==>userinfo

Func Modmif()
    
    Dim $array1, $array2, $array3, $array4, $array5
    
    $pprimuser = GUICtrlRead($primeuser)
    GUICtrlSetState($Button3, $gui_disable)
    GUISetState($primeuser, $gui_disable)
    GUISetState($floor, $gui_disable)
    GUISetState($cube1, $gui_disable)
    GUISetState($cube2, $gui_disable)
    GUISetState($cube3, $gui_disable)
    
    If Not FileExists($amosrce & "\slmpc.mif") Then
        MsgBox(0, "AMO Fix", "Problem with Mif file you will need to visit the PC.  You may need to rerun collect.")
        DriveMapDel($amosrce)
        _SelfRestart()
    EndIf
    _FileReadToArray($amosrce & "\slmpc.mif", $array1)
    $max=UBound($array1)
    if $max < 100 then
        MsgBox(0, "AMO Fix", "Problem with Mif file you will need to visit the PC.  You may need to rerun collect.")
        DriveMapDel($amosrce)
        _SelfRestart()
    EndIf
    $string1 = "Access=Write-Only"
    $string2 = "Value="
    $string3 = "EndAttribute"
    $count = 0
    For $linecount = 0 To UBound($array1) - 1
        $test1 = StringStripWS($array1[$linecount], 8)
        $result1 = StringCompare($string1, $test1, 2)
        If $result1 = 0 Then $count = $count + 1
        If $count = 1 Then ExitLoop
    Next
    $test2 = StringStripWS($array1[$linecount + 2], 8)
    $result2 = StringCompare($string3, $test2, 8)
    If $result2 = 0 Then
        $temp = StringStripWS($array1[$linecount + 1], 8)
        $cc = StringTrimLeft($temp, 6)
        GUICtrlSetData($message6, $cc)
        GUICtrlSetData($message7, $pcostcenter)
        $linecount = $linecount + 1
        ;MsgBox(0, "Test2", $linecount & '   ' & $pcostcenter)
        _FileWriteToLine($amosrce &"\slmpc.mif",$linecount,"    Value = "& $pcostcenter,1)
    Else
        $test3 = StringStripWS($array1[$linecount + 1], 8)
        $result3 = StringCompare($string3, $test3, 8)
        If $result3 = 0 Then
            $lc = 21
            GUICtrlSetData($message6, "none")
            GUICtrlSetData($message7, $pcostcenter)
            $linecount = $linecount + 1
            ;MsgBox(0, "Test3", $linecount & '   ' & $pcostcenter)
            _FileWriteToLine($amosrce &"\slmpc.mif",$linecount,"    Value = "& $pcostcenter,0)
        EndIf
    EndIf
    
    
    _FileReadToArray($amosrce & "\slmpc.mif", $array2)
    ;_ArrayDisplay($array2, "Array2")
    $count = 0
    For $linecount = 0 To UBound($array2) - 1
        $test4 = StringStripWS($array2[$linecount], 8)
        $result4 = StringCompare($string1, $test4, 2)
        If $result4 = 0 Then $count = $count + 1
        If $count = 3 Then ExitLoop
    Next
    $test5 = StringStripWS($array2[$linecount + 2], 8)
    $result5 = StringCompare($string3, $test5, 2)
    If $result5 = 0 Then
        $temp2 = StringStripWS($array2[$linecount + 1], 8)
        $pu = StringTrimLeft($temp2, 6)
        GUICtrlSetData($message8, $pu)
        GUICtrlSetData($message9, $pprimuser)
        $linecount = $linecount + 1
        ;MsgBox(0, "Test5", $linecount & '   ' & $pprimuser)
        _fileWritetoline($amosrce &"\slmpc.mif", $linecount, "    Value = "& $pprimuser,1)
        
    Else
        $test6 = StringStripWS($array2[$linecount + 1], 8)
        $result6 = StringCompare($string3, $test6, 8)
        If $result6 = 0 Then
            GUICtrlSetData($message8, "none")
            GUICtrlSetData($message9, $pprimuser)
            $linecount = $linecount + 1
            ;MsgBox(0, "Test6", $linecount & '   ' & $pprimuser)
            _fileWritetoline($amosrce &"\slmpc.mif", $linecount, "    Value = "& $pprimuser,0)
        EndIf
    EndIf

    
    _FileReadToArray($amosrce & "\slmpc.mif", $array4)
    ;_ArrayDisplay($array4, "Array4")
    $count = 0
    $building = "WILKES-BARRE"
    For $linecount = 0 To UBound($array4) - 1
        $test7 = StringStripWS($array4[$linecount], 8)
        $result7 = StringCompare($string1, $test7, 2)
        If $result7 = 0 Then $count = $count + 1
        If $count = 8 Then ExitLoop
    Next
    $test8 = StringStripWS($array4[$linecount + 2], 8)
    $result8 = StringCompare($string3, $test8, 2)
    If $result8 = 0 Then
        $temp4 = StringStripWS($array4[$linecount + 1], 8)
        $bu = StringTrimLeft($temp4, 6)
        GUICtrlSetData($message12, $bu)
        GUICtrlSetData($message13, $building)
        $linecount = $linecount + 1
        ;MsgBox(0, "Test8", $linecount & '   ' & $building)
        _fileWritetoline($amosrce &"\slmpc.mif",$linecount, "    Value = "& $building,1)
    Else
        $test9 = StringStripWS($array4[$linecount + 1], 8)
        $result9 = StringCompare($string3, $test9, 2)
        If $result9 = 0 Then
            GUICtrlSetData($message12, "none")
            GUICtrlSetData($message13, $building)
            $linecount = $linecount + 1
            ;MsgBox(0, "Test9", $linecount & '   ' & $building)
            _fileWritetoline($amosrce &"\slmpc.mif",$linecount, "    Value = "& $building,0)
        EndIf
    EndIf
    


    _FileReadToArray($amosrce & "\slmpc.mif", $array3)
    ;_ArrayDisplay($array3, "Array3")
    $count = 0
    For $linecount = 0 To UBound($array3) - 1
        $test10 = StringStripWS($array3[$linecount], 8)
        $result10 = StringCompare($string1, $test10, 2)
        If $result10 = 0 Then $count = $count + 1
        If $count = 9 Then ExitLoop
    Next
    $test11 = StringStripWS($array3[$linecount + 2], 8)
    $result11 = StringCompare($string3, $test11, 2)
    If $result11 = 0 Then
        $lc = 123
        $temp = StringStripWS($array3[$linecount + 1], 8)
        $fl = StringTrimLeft($temp, 6)
        GUICtrlSetData($message10, $fl)
        GUICtrlSetData($message11, $floor1)
        $linecount = $linecount + 1
        ;MsgBox(0, "Test11", $linecount & '   ' & $floor1)
        _fileWritetoline($amosrce &"\slmpc.mif",$linecount, "    Value = "& $floor1 ,1)
    Else
        $test12 = StringStripWS($array3[$linecount + 1], 8)
        $result12 = StringCompare($string3, $test12, 2)
        If $result12 = 0 Then
            $lc = 123
            GUICtrlSetData($message10, "none")
            GUICtrlSetData($message11, $floor1)
            $linecount = $linecount + 1
            ;MsgBox(0, "Test12", $linecount & '   ' & $floor1)
            _fileWritetoline($amosrce &"\slmpc.mif",$linecount, "    Value = "& $floor1,0)
        EndIf
    EndIf

    _FileReadToArray($amosrce & "\slmpc.mif", $array5)
    $count = 0
    For $linecount = 0 To UBound($array5) - 1
        $test13 = StringStripWS($array5[$linecount], 8)
        $result13 = StringCompare($string1, $test13, 2)
        If $result13 = 0 Then $count = $count + 1
        If $count = 10 Then ExitLoop
    Next
    $test14 = StringStripWS($array5[$linecount + 2], 8)
    $result14 = StringCompare($string3, $test14, 2)
    If $result14 = 0 Then
        $lc = 132
        $temp7 = StringStripWS($array5[$linecount + 1], 8)
        $cu = StringTrimLeft($temp7, 6)
        GUICtrlSetData($message14, $cu)
        GUICtrlSetData($message15, $pcube)
        $linecount = $linecount + 1
        _fileWritetoline($amosrce &"\slmpc.mif",$linecount, "    Value = "& $pcube ,1)
    Else
        $test15 = StringStripWS($array5[$linecount + 1], 8)
        $result12 = StringCompare($string5, $test15, 2)
        If $result15 = 0 Then
            $lc = 132
            GUICtrlSetData($message14, "none")
            GUICtrlSetData($message15, $pcube)
            $linecount = $linecount + 1
            _fileWritetoline($amosrce &"\slmpc.mif",$linecount, "    Value = "& $pcube,0)
        EndIf
    EndIf



    _FileReadToArray($amosrce & "\slmpc.mif", $array5)
    ;_ArrayDisplay($array5,"MIF File")
    Sleep(8000)
    DriveMapDel($amosrce)
    _SelfRestart()
EndFunc   ;==>Modmif

Func _SelfRestart()
    If @Compiled Then
        Run(FileGetShortName(@ScriptFullPath))
    Else
        Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
    EndIf
    Exit
EndFunc   ;==>_SelfRestart






Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    Local $From = BitAND($wParam, 0xFFFF)
    Local $Code = BitShift($wParam, 16)
    Local $Data

    Switch $Code
        Case $EN_CHANGE
            Switch $From
                Case $cube1
                    $Data = StringLeft(StringRegExpReplace(StringUpper(GUICtrlRead($From)), '[^A-E]', ''), 1)
                    If $Data Then
                        _WinAPI_SetFocus(GUICtrlGetHandle($cube2))
                    EndIf
                Case $cube2, $cube3
                    $Data = StringLeft(StringRegExpReplace(GUICtrlRead($From), '[^\d]', ''), 2)
                    If (StringLen($Data) = 2) And ($From = $cube2) Then
                        _WinAPI_SetFocus(GUICtrlGetHandle($cube3))
                    EndIf
                Case Else
                    Return $GUI_RUNDEFMSG
            EndSwitch
            GUICtrlSetData($From, $Data)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

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