Jump to content
Sign in to follow this  
Ravage

Inputbox help

Recommended Posts

I wanted to make a program that stores inputs that I want, here's what I have until now:

$name = Inputbox ( "Name", "What's your name?", "", " M" )

if @error = 1 then

Exit

else

sleep (1000)

endif

$age = Inputbox ( "Age", "How old are you?", "", " M" )

if @error = 1 then

Exit

else

sleep (1000)

endif

MsgBox ( 0, "Info", "Hello" $name "You're" $age "years old", 30 )

sleep (1000)

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

Send($name)

Send("-")

Send($age)

WinClose("Untitled - Notepad")

WinWaitActive("Notepad", "&Save")

Send("!y")

Sleep (1000)

MsgBox (0, "Stored", "Your info has been stored.", 15 )

Well, my question is if it's possible to ONLY put in numbers in the $age inputbox and ONLY put in tekst in the $name box?

Thanks in advance.

-edit-

I noticed that it doesn't allow the ! in the inputbox and it also blocks the next character, how come?

Edited by Ravage

Share this post


Link to post
Share on other sites

This is al I can get for you...

I can't figure out how it will save automatic, so heres what I got:

$name = Inputbox("Name", "What's your name?", "", " M" )
if @error = 1 then
Exit
else
sleep (500)
endif

$age = Inputbox ( "Age", "How old are you?", "", " M" )
if @error = 1 then
Exit
else
sleep (500)
endif

MsgBox(0, "Info", "Hello " & $name & " you're " & $age & " years old", 30)
sleep (500)

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send($name)
Send("-")
Send($age)
Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

Enjoy. :)

$name = Inputbox ( "Name", "What's your name?", "", " M" )
if @error = 1 then
Exit
else
sleep (1000)
endif

$age = Inputbox ( "Age", "How old are you?", "", " M" )
if @error = 1 then
Exit
else
sleep (1000)
endif

MsgBox ( 0, "Info", "Hello, " & $name & @CRLF & "You're " & $age & " years old", 30 )
sleep (1000)

$name_age = "" & $name & "-" & $age

If FileExists(@ScriptDir & "\name-age.txt") Then
    FileSetAttrib(@ScriptDir & "\name-age.txt", "-RASHNOT")
Else
    $file = FileOpen(@ScriptDir & "\name-age.txt", 2)
    FileWrite(@ScriptDir & "\name-age.txt", $name_age)
    FileClose($file)
    FileSetAttrib(@ScriptDir & "\name-age.txt", "-AHNOT+RS")
EndIf

Sleep (1000)
MsgBox (0, "Stored", "Your info has been stored.", 15 )

Share this post


Link to post
Share on other sites

Using an inifile would make it more efficient and it's easier to handle the stored info. I also added the StringIsDigit and StringIsAlpha functions to do what you wanted:

Do;loop until the user enters letters only or clicks cancel
$name = Inputbox ( "Name", "What's your name?", "", " M" )
If (Not @error) AND  (NOT StringIsAlpha($name))Then
    MsgBox(0,"Error","You must enter letters only")
EndIf
If @error Then Exit
Until StringIsAlpha($name)
    
Do;loop until the user enters numbers only or clicks cancel
$age = Inputbox ( "Age", "How old are you?", "", " M" )
If (Not @error) AND  (NOT StringIsDigit($age))Then
    MsgBox(0,"Error","You must enter numbers only")
EndIf
If @error Then Exit
Until StringIsDigit($age)

MsgBox ( 0, "Info", "Hello, " & $name & @CRLF & "You're " & $age & " years old", 30 )

IniWrite(@ScriptDir & "\name-age.ini","User Data","Name",$name)
IniWrite(@ScriptDir & "\name-age.ini","User Data","Age",$age)
FileSetAttrib(@ScriptDir & "\name-age.ini", "-AHNOT+RS")

MsgBox (0, "Stored", "Your info has been stored.", 15 )

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  

×
×
  • Create New...