将密钥发送到活动窗口

发布于 2024-09-30 01:14:57 字数 182 浏览 4 评论 0原文

嘿。 我不知道这是否可行,但值得一试。假设有一款不使用鼠标的第三方赛车游戏。有没有办法让我创建一个 Windows 窗体应用程序,它侦听鼠标单击并将相应的键传输到游戏/活动窗口(例如,左键单击将发送“向上箭头”键来加速,右键单击将通过发送‘向下箭头’键)。我查看了 SendKeys 方法,但一旦游戏成为活动窗口,它就不起作用。有什么想法吗?谢谢

Hey.
I don't know if this is possible, but worth a shot. Say there's a third party racing game which doesn't use the mouse. Is there a way for me to create a Windows Form app which listens for mouse clicks and transfers a corresponding key to the game/active window (e.g. Left click would send the 'Up arrow' key to accelerate the Right click would decelerate by sending the 'Down arrow' key). I've looked at the SendKeys method, but it doesn't work once the game becomes the active window. Any ideas? Thanks

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

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

发布评论

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

评论(2

红焚 2024-10-07 01:14:57

如果游戏使用 DirectInput 读取按键,则 SendKeys 将无法工作,因为 DI 在驱动程序级别工作,而 SendKeys/SendInput 在 API 级别工作,这对于游戏来说可能太“高”而无法看到。你可以Hook到DirectInput,并向其发送命令,但是它的不会是单行本,如果您是 DirectX 新手,您不会觉得它有什么乐趣。

if the game uses DirectInput for reading the keys, then SendKeys wont work, as DI works at driver level, and SendKeys/SendInput works at API level, which may be too 'high' for the game to see. you can Hook into DirectInput, and send it commands, but its not going to be a one liner, and if you're new to DirectX, you're not going to find it fun.

清风挽心 2024-10-07 01:14:57

我不知道它是否有效,以及是否可能,但直观上,我会检查是否有某种 C# 的 AutoIt 库。

据我所知,AutoIt向游戏发送按键事件没有任何问题。
互联网上有几种将 AutoIt 集成到 C# 的方法,但到目前为止,我还没有尝试过其中一种。

不过你还是可以尝试一下
http://www.lancelarsen.com /Blog/tabid/72/EntryId/48/AutoIt-C-Helper-Library.aspx

I don't know if it would work, and if it is possible, but intuitively, I would check if there is some kind of AutoIt Library for C#.

As far as I know, AutoIt has no problems with sending key press events to games.
A couple of methods to integrate AutoIt to C# exist on the internet, but so far, I haven't tried one of them yet.

Still you could give it a shot
http://www.lancelarsen.com/Blog/tabid/72/EntryId/48/AutoIt-C-Helper-Library.aspx

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