通过WPF应用程序向Directx游戏发送模拟击键 [英] Sending simulated keystrokes to Directx games via WPF application

查看:75
本文介绍了通过WPF应用程序向Directx游戏发送模拟击键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,codeproject。我正在制作一个WPF C#程序,该程序具有一个UI,用户可以按下按钮,将假键事件发送到同时运行的游戏(例如Halo PC)。我相信我可以使用一些DirectX api,但我不知道哪一个,如何使用它,或者如何告诉我的程序将事件发送到哪个窗口。如果这里的任何人都知道如何做到这一点,或者知道如何帮助我,那将非常感激:)

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 :)

推荐答案

我不认为这可以与DirectX有关。如果你想欺骗一些现有游戏和其他应用程序,你所能做的只是使用原始Windows API方法 SendInput

http://msdn.microsoft.com/en-us/library /windows/desktop/ms646310%28v=vs.85%29.aspx [ ^ ]。



这是如何使用的在通过P / Invoke的.NET应用程序中: http://www.pinvoke.net/default.aspx/user32。 sendinput [ ^ ]。



参见:

http:/ /en.wikipedia.org/wiki/P/Invoke [ ^ ],

http://msdn.microsoft。 com / library / zh-cn / vcmxspec / html /vcmg_PlatformInvocationServices.asp [ ^ ]。



这是真正的低级API,与硬件驱动程序相同或类似在他们的实现中使用。在所有情况下都没有其他任何工作。此外,您应该了解不应将其用于UI开发。它只能用于不提供任何其他类型协作的应用程序上的技巧;其他示例包括UI测试软件的创建或键盘和/或鼠标宏的回放。对于UI开发,这将是纯粹的,非常不切实际的滥用。



-SA
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:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx[^].

This is how it can be used in a .NET application via P/Invoke: http://www.pinvoke.net/default.aspx/user32.sendinput[^].

See also:
http://en.wikipedia.org/wiki/P/Invoke[^],
http://msdn.microsoft.com/library/en-us/vcmxspec/html/vcmg_PlatformInvocationServices.asp[^].

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.

—SA


这篇关于通过WPF应用程序向Directx游戏发送模拟击键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆