I can send any windows application key strokes with PostMessage api. But I can’t send key strokes to Game window by using PostMessage.
Anyone know anything about using Direct Input functions for sending keys to games from C#.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An alternate way would be to hook the DirectInput API directly – Microsoft Research has provided a library to do this already: http://research.microsoft.com/en-us/projects/detours/
Once you hook into the API, you can do whatever you want with it. However, it’s worth noting that in recent versions of Windows, DirectInput for mouse & keyboard input is just a wrapper around the Win32 windows messages. DirectInput spawns a thread in the background and simply intercepts window messages before passing them along back to the application. It’s one of the reasons why Microsoft no longer recommends the use of DirectInput – and it means that messaging APIs like PostMessage should work just fine.