Modify

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#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 follow-up: Changed 16 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

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.

comment:2 in reply to: ↑ 1 Changed 16 years ago by anonymous

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 follow-up: Changed 16 years ago by Valik

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().

comment:4 in reply to: ↑ 3 ; follow-up: Changed 16 years ago by paulpmeier

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

Paul

comment:5 in reply to: ↑ 4 Changed 16 years ago by paulpmeier

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

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.