Ravage Posted September 21, 2007 Share Posted September 21, 2007 (edited) 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 Exitelsesleep (1000)endif$age = Inputbox ( "Age", "How old are you?", "", " M" )if @error = 1 then Exitelsesleep (1000)endifMsgBox ( 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 September 21, 2007 by Ravage Link to comment Share on other sites More sharing options...
AlmarM Posted September 21, 2007 Share Posted September 21, 2007 (edited) 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 September 21, 2007 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. Link to comment Share on other sites More sharing options...
aslani Posted September 21, 2007 Share Posted September 21, 2007 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 ) [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
Nahuel Posted September 21, 2007 Share Posted September 21, 2007 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 ) Link to comment Share on other sites More sharing options...
Ravage Posted September 21, 2007 Author Share Posted September 21, 2007 Thank you all for your help, it works now Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now