Greek Posted September 28, 2009 Share Posted September 28, 2009 Never saw this for AutoIt, Can someone make me an example for this with the Dos Console? Enter your Name: Greek Your Name is Greek Thanks Greek Link to comment Share on other sites More sharing options...
TurionAltec Posted September 28, 2009 Share Posted September 28, 2009 ConsoleRead, ConsoleWrite. Though when compiled and run from a commandprompt, the "ConsoleRead" won't work as expected, though it will work in the Scite ouput pane. http://www.autoitscript.com/forum/index.php?showtopic=72563 Link to comment Share on other sites More sharing options...
Inverted Posted September 28, 2009 Share Posted September 28, 2009 (edited) You can use the FileOpen method shown here : http://www.autoitscript.com/forum/index.php?showtopic=79275&st=0&p=571658&#entry571658 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** $maxchr = 123 $input = "" ConsoleWrite(@CRLF&"Enter your Name:"&@CRLF) $file = FileOpen("con", 4) $line = BinaryToString(FileRead($file, $maxchr)) FileClose($file) ConsoleWrite("Your name is: " & $line & @CRLF) Sleep(2000) ; I put a sleep here, so you don't have to run it from the cmd to see the output P.S.: Of course it's much easier to use InputBox and MsgBox Edited September 28, 2009 by Inverted Link to comment Share on other sites More sharing options...
TurionAltec Posted September 28, 2009 Share Posted September 28, 2009 That would have been handy a year and a half ago. Link to comment Share on other sites More sharing options...
Greek Posted September 28, 2009 Author Share Posted September 28, 2009 You can use the FileOpen method shown here : http://www.autoitscript.com/forum/index.php?showtopic=79275&st=0&p=571658&#entry571658 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** $maxchr = 123 $input = "" ConsoleWrite(@CRLF&"Enter your Name:"&@CRLF) $file = FileOpen("con", 4) $line = BinaryToString(FileRead($file, $maxchr)) FileClose($file) ConsoleWrite("Your name is: " & $line & @CRLF) Sleep(2000) ; I put a sleep here, so you don't have to run it from the cmd to see the output P.S.: Of course it's much easier to use InputBox and MsgBox I Compile it and run it, but nothing to see there? Link to comment Share on other sites More sharing options...
Inverted Posted September 28, 2009 Share Posted September 28, 2009 You need to compile as a console application (select compile with options) If you haven't got that option, then you need to downlod the full Scite ! (from the main page) Link to comment Share on other sites More sharing options...
Greek Posted September 29, 2009 Author Share Posted September 29, 2009 Create CUI instead GUI ist already checked. Link to comment Share on other sites More sharing options...
Inverted Posted October 2, 2009 Share Posted October 2, 2009 Create CUI instead GUI ist already checked.Run it from a command prompt, what happens ? Link to comment Share on other sites More sharing options...
zodiac Posted October 5, 2009 Share Posted October 5, 2009 Nice trick, Inverted. Thanks for sharing. Just did a little function to help with this: Func _ConsoleRead($StripCRLF=1) ;If called with no parameters, it returns the user input stripped from CRLF, which should be the expected behaviour. Local $maxchr = 123 Local $file = FileOpen("con", 4) Switch $StripCRLF Case 1 Return StringReplace(BinaryToString(FileRead($file, $maxchr)),@CRLF,"") Case 0 Return BinaryToString(FileRead($file, $maxchr)) EndSwitch FileClose($file) EndFunc ;==>_ConsoleRead For Greek: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ConsoleWrite("Enter your Name:" & @CRLF) $name = _ConsoleRead() ConsoleWrite("Your name is " & $name) Func _ConsoleRead($StripCRLF=1) ;If called with no parameters, it returns the user input stripped from CRLF, which should be the expected behaviour. Local $maxchr = 123 Local $file = FileOpen("con", 4) Switch $StripCRLF Case 1 Return StringReplace(BinaryToString(FileRead($file, $maxchr)),@CRLF,"") Case 0 Return BinaryToString(FileRead($file, $maxchr)) EndSwitch FileClose($file) EndFunc ;==>_ConsoleRead 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