LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2221|回复: 4

怎样获得当前桌面下的鼠标和键盘事件?

[复制链接]
发表于 2007-8-14 10:37:50 | 显示全部楼层 |阅读模式
在winodw里面可以用HOOK来绑定系统的API,可以在程序中获得鼠标和键盘的事件,那么请问一下在 linux下要怎么实现啊?能否用X WINDOW的系统函数来实现呢?
     我现在只能在自己打开的DISPLAY里面获得这些事件,不知道是不是可以获得GNOME的桌面。请大侠指点,谢过!
发表于 2007-8-14 11:12:01 | 显示全部楼层
从GtkWidget对象的signal注册入手。g_signal_newv 等函数。
用g_signal_override_class_closure重载GtkWidget对象的signal处理。
还可以用 g_signal_add_emission_hook来加载钩子函数。

    *

      RUN_FIRST: if the G_SIGNAL_RUN_FIRST flag was used during signal registration and if there exist a class_closure for this signal, the class_closure is invoked. Jump to EMISSION_HOOK state.
    *

      EMISSION_HOOK: if any emission hook was added to the signal, they are invoked from first to last added. Accumulate return values and jump to HANDLER_RUN_FIRST state.
    *

      HANDLER_RUN_FIRST: if any closure were connected with the g_signal_connect family of functions, and if they are not blocked (with the g_signal_handler_block family of functions) they are run here, from first to last connected. Jump to RUN_LAST state.
    *

      RUN_LAST: if the G_SIGNAL_RUN_LAST flag was set during registration and if a class_closure was set, it is invoked here. Jump to HANDLER_RUN_LAST state.
    *

      HANDLER_RUN_LAST: if any closure were connected with the g_signal_connect_after family of functions, if they were not invoked during HANDLER_RUN_FIRST and if they are not blocked, they are run here, from first to last connected. Jump to RUN_CLEANUP state.
    *

      RUN_CLEANUP: if the G_SIGNAL_RUN_CLEANUP flag was set during registration and if a class_closure was set, it is invoked here. Signal emission is completed here.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-8-14 11:31:10 | 显示全部楼层
我详细一下我的需求。我要写一个DEAMON进程,用来监测现在系统中的鼠标和键盘事件,做个记录,比如什么时候点了鼠标。谢谢LS的版主,能不能请你稍微详细一点我接触LINUX编程不长时间。
回复 支持 反对

使用道具 举报

发表于 2007-8-14 19:57:29 | 显示全部楼层
从GTK入手, 应该可行.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-8-15 13:31:17 | 显示全部楼层
无语。。。。。看来大侠都是抽象派的
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表