发送到游戏击键 [英] Send Key Strokes to Games

查看:130
本文介绍了发送到游戏击键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以发送PostMessage的(任何Windows应用程序击键)api.But我不能发送击键使用PostMessage的到游戏窗口。

I can send any windows application key strokes with PostMessage() api.But i cant send key strokes to Game window by using PostMessage.

任何人都知道什么用。直接输入功能,从C#发送键游戏

Anyone know anything about using Direct Input functions for sending keys to games from C#.

推荐答案

另一种方法是直接挂钩的DirectInput API - 微软研究院提供了一个库已经做到这一点: http://research.microsoft.com/en-us/projects/弯路/

An alternate way would be to hook the DirectInput API directly - Microsoft Research has provided a library to do this already: http://research.microsoft.com/en-us/projects/detours/

一旦你钩到API,你可以做任何你想用它。不过,值得注意的是,在最近版本的Windows,DirectInput的对鼠标和放大器;键盘输入就在Win32的Windows消息的包装。 DirectInput的产卵在后台线程,并沿传递回给应用程序之前只是截取窗口消息。这就是为什么微软不再建议使用DirectInput的原因之一 - 这意味着,消息传递API像PostMessage的的的工作就好了。

Once you hook into the API, you can do whatever you want with it. However, it's worth noting that in recent versions of Windows, DirectInput for mouse & keyboard input is just a wrapper around the Win32 windows messages. DirectInput spawns a thread in the background and simply intercepts window messages before passing them along back to the application. It's one of the reasons why Microsoft no longer recommends the use of DirectInput - and it means that messaging APIs like PostMessage should work just fine.

这篇关于发送到游戏击键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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