Jump to content
  • Advertisement
Sign in to follow this  
maratoid

Sending keystrokes to a game window

This topic is 5457 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I'm witing an application that sends series of keypresses to a game window based on voice input from a user. I've been trying to do this using SendInput() API - this approach works only with applications that are not using DirectInput. After much research on Google and newsgroups I've also tried to write a keyboard filter, based on some samples from Windows DDK, which I really wish I didn't have to do - because I have exactly zero experience with writing drivers. Also this approach seems to only work if user's keyboard is hooked up through ps/2 port. I've also tried to use the DInput SendDeviceData() API, which also didn't work - the sample code I've found is outdated and apparently Microsoft actually recommends against using this API for what I'm trying to do. I know, that what I am trying to do is possible, since there are products out there that do similar things (Game Commander). So my question is: what would be a better way to accomplish this? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Use an API hook on the DInput functions GetDeviceData and GetDeviceState and inject your keystates there. I guess gamecommander etc. uses some "Microsoft way" to do it, never heard how they do it, probably with a device driver.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just in case someone will need this in the future:

SendInput does work with DInput games on Win2k and WinXP - you just have to make sure that both wVk and wScan (VK code and Hardware Scan code) members of the KEYBDINPUT struct are filled with appropriate values.

Thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!