Modify

#544 closed Bug (No Bug)

Read from console with FileRead

Reported by: paulpmeier Owned by:
Milestone: Component: Documentation
Version: 3.2.12.0 Severity: None
Keywords: Cc:

Description

The description of this feature I missed in the AutoIt Help:
FileOpen("con", 4) opens console for binary input.

#AutoIt3Wrapper_Change2CUI=y

$input = ""
ConsoleWrite(@CRLF & "Write some text and close with ENTER: ")

$file = FileOpen("con", 4)
While 1
	$chr = FileRead($file, 1)
	If $chr = @CR Then ExitLoop
	$input = $input & BinaryToString($chr)
WEnd
FileClose($file)

ConsoleWrite(@CRLF & "Input was: " & $input & @CRLF)

Compile as CUI and start the exe-file from console prompt.
(Tested with AutoIt 3.2.12.1 and Windows XP SP2)

Paul

Attachments (0)

Change History (5)

comment:1 by Valik, on Aug 28, 2008 at 6:10:58 PM

Resolution: No Bug
Status: newclosed

This doesn't need documented. There is a native AutoIt function for doing the same thing so I don't feel that it is necessary for us to document alternate ways.

in reply to:  1 comment:2 by anonymous, on Aug 29, 2008 at 8:59:59 AM

Hi Valik,

thank you for your reply.
Please give me an example. How can I read keystrokes from the console prompt with ConsoleRead?

comment:3 by Valik, on Aug 29, 2008 at 5:10:09 PM

You could probably use the C-Runtime function _getch() which is exported from msvcrt.dll. You could also try out some of the Windows API console-specific functions like ReadConsole() or ReadConsoleInput(). These would, of course, need to be used via DllCall().

in reply to:  3 ; comment:4 by paulpmeier, on Aug 30, 2008 at 6:27:59 AM

Thank you, Valik for this information.
I will try the API-functions.

Paul

in reply to:  4 comment:5 by paulpmeier, on Aug 30, 2008 at 9:44:38 AM

Thank you again, Valik.

I have tested the _getch() function. I didn't know, that it's so easy to use the C-functions in AutoIt.

Paul

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.