Hey. I don't know if this is possible, but worth a shot. Say there's a third party racing game which doesn't use the mouse. Is there a way for me to create a Windows Form app which listens for mouse clicks and transfers a corresponding key to the game/active window (e.g. Left click would send the 'Up arrow' key to accelerate the Right click would decelerate by sending the 'Down arrow' key). I've looked at the SendKeys method, but it doesn't work once the game becomes the active window. Any ideas? Thanks
2 Answers
if the game uses DirectInput for reading the keys, then SendKeys wont work, as DI works at driver level, and SendKeys/SendInput
works at API level, which may be too 'high' for the game to see. you can Hook into DirectInput, and send it commands, but its not going to be a one liner, and if you're new to DirectX, you're not going to find it fun.

- 3,424
- 1
- 25
- 46
-
I don't mind going low level via interop. However, is there another way that could be lower level than DirectInput? i.e. does Windows have a native command that can be accessed to send to? – XSL Nov 02 '10 at 01:12
-
directX would be lower level than interop. as far as i know, its the lowest 'easy' way to get access to the hardware, anything else, and you're in device driver land. if i'm mistaken, i'm sure someone else will provide an answer quick enough. the game may not use directX though, but almost all of them do. you can also look into `SendMessage WM_CHAR`, which would be easier to test than any DX solution – jasper Nov 02 '10 at 01:44
I don't know if it would work, and if it is possible, but intuitively, I would check if there is some kind of AutoIt Library for C#.
As far as I know, AutoIt has no problems with sending key press events to games. A couple of methods to integrate AutoIt to C# exist on the internet, but so far, I haven't tried one of them yet.
Still you could give it a shot http://www.lancelarsen.com/Blog/tabid/72/EntryId/48/AutoIt-C-Helper-Library.aspx

- 1,504
- 1
- 15
- 27