Solved

Sending keystrokes to DirectX applications.

Posted on 2004-08-19
5
629 Views
Last Modified: 2008-03-03
I need a way to send keystrokes to a DirectX (3.0+) application.  I've tried Sendkeys, as well as the keybd_event API, no luck, the keystrokes never arrive.

Anyone know?
0
Comment
Question by:fizycist
  • 3
5 Comments
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 11852514
Hmm, I would guess it is using DirectInput, from MSDN
"Microsoft DirectInput Overview
Apart from providing services for devices not supported by the Microsoft Win32 API, Microsoft DirectInput gives faster access to input data by communicating directly with the hardware drivers rather than relying on Microsoft Windows messages."
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 11852705
You might try using the On-Screen keyboard (Under Accessories --> Accessibility)  If you can drive it with On-Screen Keyboard, there is some way to drive it programatically.
0
 

Author Comment

by:fizycist
ID: 11856785
Ok, I tried on screen keyboard.  This game will accept some keystrokes from it, not all.  The keystrokes for movement are not accepted, and these are the ones I need.  I tried remapping the keys in the game, but no luck.

So can I slip keystrokes in with DirectInput?  How?

(btw this is for a neural network demonstration, the goal is to teach a NN to play this simple game (Subspace / Contiuum.  The software can already read the screen and identify objects, but simply cannot act on its decisions, arghh)
0
 
LVL 16

Accepted Solution

by:
JohnBPrice earned 130 total points
ID: 11901808
I think slipping keystrokes in to DirectInput might be tough.  DirectInput gives the app direct access to the keyboard driver, nothing in Windows interferes while the app is the active app.  Some ideas would be to find a keyboard driver that supports this kind of thing (I don't know if they exist), buy/make a hardware device to slip in between your real keyboard and the computer (the home built flight simulator guys seem to have some experience here, search for keyboard eumulator simulator), maybe you could hook into the calls to DirectInput, catch when they try to capture the keyboard, and thus find their input routine which you could fake key presses into.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question