在Linux中使用c ++的库注册热键 [英] Register hotkeys in Linux using library for c++

查看:310
本文介绍了在Linux中使用c ++的库注册热键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有任何库的linux wroted在C + +可以注册全局热键为我的应用程序?感谢。

解决方案

您必须提供更多资讯。



在Gnome中,全局功能因窗口管理器而异。 Metacity具有可配置的全局快捷方式,Compiz和Sawfish也是如此,并且它们的配置不同。 Xhotkey 也可用于相同的功能。



在KDE应用程序框架中, KAction 可以注册在程序中执行操作的全局快捷方式。这些实际上由kded(按需启动)中的模块处理,因此它们甚至在KDE桌面环境之外工作。



如果不使用KDE框架,但仍在使用X11,则可以使用xlib API在根窗口中调用 XGrabKey 。 / p>

对于在X以外工作的快捷方式,只要在2.6内核上以root身份运行(或许可权限已更改),您就可以直接打开 / dev / input / event * ,并轮询所需的关键事件。


are there any libraries for linux wroted in C++ which could register global hotkeys for my application? Thanks.

解决方案

You'll have to provide more information.

In Gnome, the global functionality varies by window manager. Metacity has configurable global shortcuts, as do Compiz and Sawfish, and they're all configured differently. Xhotkeys can also be used for the same functionality. However, these are all limited to starting applications only.

Within the KDE application framework, KAction can register global shortcuts which perform actions inside your program. These are actually handled by a module in kded (launched on demand), so they work even outside of the KDE desktop environment.

If you don't use the KDE framework, but are still using X11, you can use the xlib API to call XGrabKey on the root window.

For shortcuts that work outside of X, as long as you are running as root (or permissions are changed permissively) on a 2.6 kernel, you can directly open /dev/input/event*, and poll for the desired key events.

这篇关于在Linux中使用c ++的库注册热键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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