Author Topic: Is it possible to write to the keyboard buffer using code in QB64?  (Read 2410 times)

0 Members and 1 Guest are viewing this topic.

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
Is it possible to write to the keyboard buffer using code in QB64?
« on: September 01, 2021, 04:38:46 pm »
I have program that displays information to the user and gets input from the user entirely in a console window. There is a lot of data that gets collected from the user, requiring a good amount of typing. However, I have noticed that if I place all the responses to the program in notepad and then copy / paste to the console window, all my responses will be buffered and played back into the program from the keyboard buffer.

This has me wondering: Is there a way to inject data into the keyboard buffer from within a QB64 program?

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Is it possible to write to the keyboard buffer using code in QB64?
« Reply #1 on: September 01, 2021, 04:41:44 pm »
If you are already using copy and paste then you should look at _CLIPBOARD$ and _CLIPBOARD$(statement)
Shuwatch!

Marked as best answer by hanness on September 01, 2021, 01:12:56 pm

FellippeHeitor

  • Guest

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
Re: Is it possible to write to the keyboard buffer using code in QB64?
« Reply #3 on: September 01, 2021, 05:12:44 pm »
Wow, _ScreenPrint is precisely what I need. Just ran a small test program and this works great.

My plan was to grab responses from a user and save them all to a text file so that these could be played back as a script at a later without the user having to re-input all these responses again. The code to save all responses is easy, but then I would also need for every single input statement that first checked to see if there was a script file, then open the file, grab the appropriate line, stuff it into the input variable and bypass the prompt to the user since a script is present.

By simply stuffing all the previous responses into the keyboard buffer like this I won't need all that additional code.

This is brilliant!

As always, thanks for the help.