Author Topic: Is possible to read from the Console?  (Read 13504 times)

x64Core

  • Member
  • **
  • Posts: 80
Is possible to read from the Console?
« on: June 11, 2012, 04:17:13 AM »
Hello guys, just I want to if is possile to read from the console?
took several hours searching, and I find nothing  :shock: it's impossible?
My last hope is the forum where I know the wisest people in programming  :biggrin:

qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: Is possible to read from the Console?
« Reply #1 on: June 11, 2012, 04:21:31 AM »
WinAPI: ReadFile,ReadConsole
CRT: scanf,...
MASM32: input$()-macro,StdIn,...
...
MREAL macros - when you need floating point arithmetic while assembling!

x64Core

  • Member
  • **
  • Posts: 80
Re: Is possible to read from the Console?
« Reply #2 on: June 11, 2012, 04:50:43 AM »
 :biggrin: thanks you qWord!  :bgrin:

Vortex

  • Member
  • *****
  • Posts: 2794
Re: Is possible to read from the Console?
« Reply #3 on: June 11, 2012, 06:20:47 AM »

x64Core

  • Member
  • **
  • Posts: 80
Re: Is possible to read from the Console?
« Reply #4 on: June 11, 2012, 07:45:41 AM »
Hi RHL,

Here is a Simple console piping example

thanks Vortex, yeah, in really I wanted read, but data are already written on the console, not from the start of a function :P thanks guys

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Is possible to read from the Console?
« Reply #5 on: June 11, 2012, 12:41:52 PM »
Here is the old HangMan example, demonstrating how to use Locate(x,y) in console mode. Another simple example:

include \masm32\MasmBasic\MasmBasic.inc   ; download
   Init
   .Repeat
      Let esi=Input$("What's your name? ", "RHL")
      .Break .if word ptr [esi]!="HR"
      Print "I asked for your name, not your nick!", CrLf$
   .Until 0
   Inkey "Hi ", esi, ", how are you?"
   Exit
end start

KeepingRealBusy

  • Member
  • ***
  • Posts: 426
Re: Is possible to read from the Console?
« Reply #6 on: June 11, 2012, 12:52:02 PM »
Hi RHL,

Here is a Simple console piping example

thanks Vortex, yeah, in really I wanted read, but data are already written on the console, not from the start of a function :P thanks guys

RHL,

You can read the console output buffer, but only for your console screen, not an arbitrary console screen. See the API for GetConsoleScreenBufferInfo.

Dave.

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Is possible to read from the Console?
« Reply #7 on: June 11, 2012, 01:00:08 PM »
It basically boils down to
Code: [Select]
invoke GetStdHandle, STD_INPUT_HANDLE
...
invoke SetConsoleMode, eax, ENABLE_LINE_INPUT or ENABLE_ECHO_INPUT or ENABLE_PROCESSED_INPUT
...
invoke ReadFile, hInput, pBuffer, bLen, ADDR bRead, NULL