捕获键盘输入和钩子的后果
我正在编写一个 VoIP 程序,标准功能之一是按键通话,这意味着按住某个键即可录制和发送音频。无论您是在玩视频游戏还是将焦点放在另一个窗口上,按键都会做出反应。
我的问题;
- 所有 VoIP 程序都明确使用键盘挂钩来实现此目的吗?例如,ventrilo/teamspeak/skype/mumble
- 我听说键盘挂钩会对系统造成性能影响,因为每个键盘消息也会发送到 VoIP 应用程序。有没有办法降低成本,对性能的影响有多大?在我的应用程序中,我的首要任务是性能和有效、计算机资源的低使用。
提前致谢
I am writing a VoIP program and one of the standard features is press-to-talk, meaning while holding down a key you record and send audio. The key will react no matter if you are in a videogame or has focus on another window.
My questions;
- do all VoIP programs explicitly use keyboard hooks to achieve this? For example, ventrilo/teamspeak/skype/mumble
- I have heard keyboard hooks incur a peformance hit on the system since every keyboard message is sent to the VoIP application too. Is there a way to reduce the cost, and how big is the performance hit? My number one priority in my application is performance and effective, low use of computer resources.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
性能影响和成本与处理程序代码所做的工作量成正比。
如果您阅读文档,它会说这些是一些原因这样做(强调我的):
The performance hit and cost are directly proportional to the amount of work your handler code does.
If you read the documentation it says that these are some of the reasons to do so (emphasis mine):
我不知道其他程序使用什么。
使用一下看看是否有性能问题。此时您可能正在进行预优化。我已经看到它在 Pentium I 硬件上的 Windows 应用程序中使用,没有产生明显的影响。
I don't know what other programs use.
Use it and see if there is a performance problem. You're probably pre-optimizing at this point. I've seen it used in Windows apps on Pentium I hardware with no noticeable impact.