Click here to Skip to main content
15,742,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, codeproject. I'm in the process of making a WPF C# program that has a UI for users to press buttons that send 'fake' key events to a simultaneously running game (Halo PC, for example). I believe there is some DirectX api that I can use, but I have no idea which one, how to use it, or how tell my program which window to send the events to. If anyone here knows how to do this, or of a source that would help me out, that would be really appreciated :)

1 solution

I don't think this can be related to DirectX. If you want to trick some existing games and other applications, all you can do is to use the raw Windows API method SendInput:[^].

This is how it can be used in a .NET application via P/Invoke:[^].

See also:[^],[^].

This is really low-level API, the same or similar to what hardware drivers use in their implementations. Nothing else will work in all cases. Also, you should understand that you should not use it for UI development. It can only be used for playing tricks on applications which won't provide any other kind of collaboration; other examples include creation of UI testing software or playing back of keyboard and/or mouse macro. For UI development, it would be pure and very impractical abuse.

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900