Sending keyboard events to another application in C# that does not handle Windows events

前端 未结 5 1451
深忆病人
深忆病人 2021-02-07 21:10

here is my situation: we are writing an application that must transform Microsoft Kinect coordinates into keyboard and mouse events.

When we need to take control of the

相关标签:
5条回答
  • 2021-02-07 21:48

    You need to pInvoke Winapi sendmessage.

    http://msdn.microsoft.com/en-us/library/ms644950(v=vs.85).aspx

    http://pinvoke.net/default.aspx/user32.SendMessage

    This is what I'm using. It works but you have to read a little bit about it. This is very powerful method.

    0 讨论(0)
  • 2021-02-07 21:57

    I think following post should be an answer to your question,

    How do i send keys using a global keyboard hook?

    According to the answer, you have to use following key codes to the SendInput function, http://www.gamespp.com/directx/directInputKeyboardScanCodes.html

    0 讨论(0)
  • 2021-02-07 22:00

    Unfortunately DirectX has no built-in hooking functionality; however there are some (this one is a .Net wrapper over another one) libraries out there that can do it. You will also need to look into XInput, which deprecates DirectInput.

    0 讨论(0)
  • 2021-02-07 22:02

    You need to simulate input using SendInput. SendMessage and SendKeys tend to work at the level of windows messages - but DirectX apps don't run a traditional message loop.

    There is a page on PInvoke.NET, but I have to confess, I've not tried to use it.


    See also this thread on the GameDev.net site, where someone has worked with some of the "teething" issues that can be encountered specifically interacting with a DirectInput based application.

    0 讨论(0)
  • 2021-02-07 22:05

    This is a quick and easy solution that I'm using. Works well.

    InputSimulator

    0 讨论(0)
提交回复
热议问题