按编程方式按住键盘键 [英] Press and Hold Keyboard key programmatically

查看:120
本文介绍了按编程方式按住键盘键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款游戏,我希望在游戏竞赛的一段时间内按住或按住或按住或向左或向右键。



通常我们通过sendkey函数发送密钥但是为了保存特定值我不知道该怎么做。

I am developing a game for which i wanted to press and hold up or down or left or right key for some time the game is racing.

Normally we send keys through sendkey functions but for holding a particular value i don't know how to do it.

推荐答案

这个讨论可以帮助


是的, SendKey 非常有限。



首先,想想你为什么需要模拟一个键输入。普通的UI开发从不需要它。这仅用于创建一些系统技巧,像回放键盘宏或虚拟键盘一样。



模拟输入的综合方式是使用Windows API SendInput 通过P / Invoke。

参见 http://msdn.microsoft.com/en-us/library/ms646310(v = vs.85).aspx [ ^ ]。



-SA
Yes, SendKey is very limited.

First of all, think why would you need to simulate a key input. Normal UI development never requires it. This is only used for creation of some system tricks, suck as playing back keyboard macro or Virtual Keyboard.

The comprehensive way of simulation input is using Windows API SendInput through P/Invoke.
See http://msdn.microsoft.com/en-us/library/ms646310(v=vs.85).aspx[^].

—SA


这篇关于按编程方式按住键盘键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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