Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

How to synthesize a keystroke

dboggs
New Contributor I
966 Views

I have a Quickwin program that calls GETCHARQQ to read a keystroke. Unlike PEEKCHARQQ (which can only be used in console apps), it blocks execution until user presses a key. In certain program-determined circumstances, I need execution to continue without a user response. My idea is to have the program "put" a character into the keyboard "buffer" (perhaps not the right term) so that GETCHARQQ will respond and continue on its merry way.

Is there any way to do this? The nearest thing I can find is the API function SendInput. It looks like this is just what I need, but I am not enough of a C++ programmer to understand the documentation or how to implement it. Can anybody help?

0 Kudos
4 Replies
Steven_L_Intel1
Employee
966 Views
Since the program is blocked, how are you going to get control to insert the character?
0 Kudos
dboggs
New Contributor I
966 Views
Here's what I'm hoping (but I could be all wet): The program has a mouse event registered (mouse$move). While blocked awaiting a keystroke (such as 'y' to answer a pending question), the user will (presumably) move the mouse to click on a 'yes' button as an alternative to pressing 'y'. The registered callback routine responds to the mouse movement and detects whether the mouse is positioned over the button. So far so good; I have this much working. Now if the callback routine can write a character to the keyboard buffer, it will allow the GETCHARQQ to free its blocking. I know that another way to accomplish this is to start a second thread; one thread watches for keystrokes while another watches for mouse movement. But that seems more complicated to me than the approach described above.
0 Kudos
Steven_L_Intel1
Employee
966 Views
I wrote a program that uses SendInput, but QuickWin doesn't see the keystrokes. I think the way you'd have to do this is with subclassing, as the POKER sample does, to intercept the keystroke. I checked with our QuickWin developer and he could not think of a way to do this offhand.
0 Kudos
dboggs
New Contributor I
966 Views
Thanks for the try Steve. I was afraid that might be the case. You probably saved me a couple of hours of effort. I think I'll pursue the two-threads technique, as suggested in the documentation and the sample program PeekApp or PeekApp3.
0 Kudos
Reply