Opened on Aug 28, 2008 at 7:26:47 AM
Closed on Aug 28, 2008 at 6:10:58 PM
Last modified on Aug 30, 2008 at 9:44:38 AM
#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)
follow-up: 2 comment:1 by , on Aug 28, 2008 at 6:10:58 PM
| Resolution: | → No Bug |
|---|---|
| Status: | new → closed |
comment:2 by , 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?
follow-up: 4 comment:3 by , 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().
follow-up: 5 comment:4 by , on Aug 30, 2008 at 6:27:59 AM
Thank you, Valik for this information.
I will try the API-functions.
Paul
comment:5 by , 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

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.