如何在所有应用程序中模拟键盘输入?

发布于 2024-12-25 10:25:29 字数 351 浏览 3 评论 0原文

我正在编写一个应用程序(用 C# 编写),作为它的一部分,它必须模拟一些击键并将其发送到另一个应用程序。我正在使用 http://inputsimulator.codeplex.com/ 项目来模拟按键,它适用于许多应用程序,但在某些应用程序中事实并非如此——即真人战斗4。

我用谷歌搜索了一下,发现了很多答案,从“这是不可能的”到“你必须使用XXX库”等等。这些答案让我很害怕,甚至几乎让我相信了“我做不到那时,但是...

M$ 虚拟键盘可以工作。它适用于所有应用程序。所以这是可能的......你们中的任何人,聪明的家伙,知道我怎样才能实现这一点吗?

I'm writing an app (in C#) which as a part of it must simulate and send some key strokes to another application. I'm using http://inputsimulator.codeplex.com/ project for simulating keys, and it works in many applications, but in some it doesn't - i.e. Mortal Combat 4.

I've googled about it, and found many answers varying from 'it's impossible' to 'you must use XXX library' etc. Those answered scared me a lot, and even nearly convinced I'm not able to do it at that time, BUT...

M$ Virtual Keyboard works. It works in ALL applications. So it IS possible... Does anyone of you, clever guys, know how can I achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烦人精 2025-01-01 10:25:29

好吧,我想我终于开始工作了。我使用了 Neal P 推荐的 API Monitor,它显示了 OSK 调用和我的调用之间的微小差异。稍后,我尝试让我的调用线程在使用按下和释放键发送消息之间休眠一段时间,就是这样。

Ok, I think I finally got it to work. I used API Monitor recommended by Neal P and it showed just minimal differences between OSK calls and mine. A bit later I've tried to make my calling thread sleep some time between sending messages with press and release key and that was it.

沦落红尘 2025-01-01 10:25:29

尽管您能够实现您的目的,但实现它的方式并不能从根本上回答您的问题:如何在所有应用程序中模拟键盘输入?

在很多情况下,前面提到的常见用户模式 ​​Microsoft API 不起作用,例如使用 DirectInput API 的游戏应用程序或受保护的游戏。

我构建了一个,可以在这种情况下提供帮助,它提供了一个简单的 C API,可以在内部与设备过滤器驱动程序进行通信。它能够发送基于 DirectInput 的游戏的输入,也能够绕过一些游戏保护。我已经检查过了,它仍然能够通过使用 x64 版本的库来绕过一些已知的游戏保护。游戏保护通常仅挂钩 x86 系统的 api。好吧,最后,2012 年 2 月 18 日,这就是我所看到的事情。

Although you were able to achieve your purpose, the way you achieved it does not fundamentally answer your question: How to simulate keyboard input in ALL applications?

There's a bunch of situations where the common user mode Microsoft API already mentioned does not work, like game applications that use the DirectInput API or protected games.

I have built a library that can help in this situations, it provides a simple C API that internally communicates with device filter drivers. It is able to send input for DirectInput based games and also is able to bypass some game protections. I have checked and it is still able to bypass some known game protections by using the x64 version of the library. Game protections commonly hook only the x86 system's api. Well, at last now, 18 February 2012, this is what I'm seeing happening.

半寸时光 2025-01-01 10:25:29

查看 MSDN 上的 SendKeys

Take a look at SendKeys on MSDN

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文