Jump to content
Sign in to follow this  
maniootek

getch()

Recommended Posts

maniootek

I know it's noob question but I just can't find in funcion list.

I need something what works like getch() in C++ or cin>>a;

Share this post


Link to post
Share on other sites
Inverted

You mean console reading ?

Check this example :

#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)
Exit



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
Edited by Inverted

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.