Sign in to follow this  
Followers 0
Komawoyo

Gui Input Box

3 posts in this topic

I'm trying to make an input box that would return the values into a msgbox

I need help on limiting the inputs ( can only put numbers from 1-13 ) &

also the input box can be edited after i put my inputs in

whats the first step on making a reset button ?

how would you get the variable set to nothing if 1 of the input box was left blank

The problem?? : in the msgbox it always returns random numbers

This is all i got (100% newb :) )

#include <GUIConstants.au3>

Local $1xI1, $1xI2, $1xI3

HotKeySet("{ESC}", "Terminate")
HotKeySet("{f1}", "msgbox1")
HotKeySet("{f4}", "Info")

$Menu = GUICreate( "Menu" , 150, 50, 700, 0)
$Info = GUICtrlCreateButton("Click", 50,20, 50, 20)
GUISetState()

While 1
    Sleep(100)
$msg = GUIGetMsg()
   Select
    Case $msg = $GUI_EVENT_CLOSE
            ExitLoop 
        Case $msg = $Info
            Info()
    EndSelect
Wend


Func Info()
$Info = GUICreate( "Test" , 200, 240, -1, -1, BitOR($WS_POPUP,$WS_CAPTION), $WS_EX_TOPMOST)
GUISetFont(10)

;Row1
$1xI1 = GUICtrlCreateInput("" , 50, 5, 50, 20)
$1xI2 = GUICtrlCreateInput("" , 100, -1, 50, 20)
$1xI3 = GUICtrlCreateInput("" , 150, -1, 50, 20)

$2xI1 = GUICtrlCreateInput("" , 50, 25, 50, 20)
$2xI2 = GUICtrlCreateInput("" , 100, -1, 50, 20)
$2xI3 = GUICtrlCreateInput("" , 150, -1, 50, 20)

$K = GUICtrlCreateButton ("Ok", 100,  200, 60, 20)
GUISetState(@SW_SHOW) 
While 2
$msg2 = GUIGetMsg()
   Select
    Case $msg2 = $GUI_EVENT_CLOSE
            ExitLoop 
        Case $msg2 = $K
            GUIDelete($Info)
            Return
    EndSelect
Wend

EndFunc

func MsgBox1()
    Msgbox( 0, "Gimme Numbers", $1xI1 & $1xI2 & $1xI3 & )
    EndFunc
Func Terminate()
    Exit
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello Komawoyo, I am also very new to AutoIt but i'm gonna try and help, feel free to correct me if i'm wrong. About limiting the users input to numbers 1-13 I think you would have to check the users input with an expression something like:

If $input > 13 OR $input < 1 Then

MsgBox(0, 'Error', 'Error Message Here')

EndIf

And about your message box returning random numbers. The numbers being returned are the ID of that control you must use "GUICtrlRead()" to read the users input. Try this:

$1xI1 = GUICtrlCreateInput("" , 50, 5, 50, 20)

$value = GUICtrlRead(ID# of $1xI1)

Your users input is now stored in $value.

Hope this helps,

Tyler

Edited by Zoozle

Share this post


Link to post
Share on other sites

Check this example

#include <GUIConstants.au3>
GUICreate("test", 180, 80)
GUISetFont(12)
GUICtrlCreateLabel("please enter number", 8, 4)
$put1 = GUICtrlCreateInput("", 8, 30, 40, 25,$ES_NUMBER)
$reset = GUICtrlCreateButton("Reset", 70, 30, 80, 25)
GUISetState()
GUICtrlSetFont ($put1, 9)
$s = 2
While 1
    $msg = GUIGetMsg()
            If $msg = $GUI_EVENT_CLOSE Then ExitLoop
            If GUICtrlRead ($put1) And Number (GUICtrlRead ($put1)) > 13 Then
            MsgBox (-1, "", "MAXIMUM VALUE ALLOWED IS 13")
            GUICtrlSetData ($put1, "")
        EndIf
        If $msg = $reset Then
            GUICtrlSetData ($put1, "")
        EndIf
WEnd

hope this can helps


[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

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