Author Topic: Is there a way to have Inkey$ function when QB64 program uses a console window?  (Read 3646 times)

0 Members and 1 Guest are viewing this topic.

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
I'm working on a QB64 program that uses only a console Window but it appears that Inkey$ does not function in a console window. Is there any trick that I can use to make this work?

Marked as best answer by hanness on September 16, 2021, 01:55:06 pm

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
What you want is _CONSOLEINPUT and _CINP which is used much like the _DEVICES statement — the one command operates for keyboard and mouse input both.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
Thanks. That really helped me a lot.

I have a program using the console that has the ability to play back a script by simply dropping responses into the keyboard buffer.

To pause execution after some messages being displayed to the user I was running a

shell "pause"

With the script, I wanted to just effectively press ENTER when a pause command was run since we don't want pauses in the program when responses are scripted. The problem with this was that the QB64 keyboard buffer has no effect on the pause command run from shell, so execution would halt completely. Thanks to the info you provided I was able to resolve that issue and my scripts now run great.