如何在Ubuntu后台进程获取数据 [英] How to fetch data in a background process in Ubuntu

查看:424
本文介绍了如何在Ubuntu后台进程获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现一个Ubuntu的操作系统命令,它可以让程序读取键盘,从数据即使程序是在后台。我试着搜索了很多,但没有得到成功。如果有任何的Ubuntu / Linux的程序员知道操作系统命令,它可以让该程序的话,请与我分享它。

I am finding a Ubuntu OS command, which lets the program to read the data from keyboard even if the program is in background. I tried to search it a lot but got no success. If any Ubuntu/Linux programmer knows the OS command which lets the program to do so, Please share it with me.

我的Ubuntu编程初学者。

I am a beginner of Ubuntu programming.

推荐答案

您可以使用Linux输入子系统读取鼠标和键盘事件。如果你的应用程序有必要的权限,它只会工作。基本上,你必须为这个运行应用程序根的工作。

You can use the Linux input subsystem to read events from mice and keyboards. It will only work if your application has the necessary privileges. Basically, you have to run the application as root for this to work.

如果你不能以root身份运行,你不应该试图反正监视键盘。

If you cannot run as root, you should not be attempting to monitor the keyboard anyway.

您可以创建一个X11应用程序监视键盘事件的在当前会话的。它仅适用于当前用户,并在目前的图形环境,未必能够观察特权对话框,例如密码输入。有关详细信息,请查看您的桌面环境的应用程序快捷方式启动;所有的Linux桌面环境我曾经听说过有一个。

You can create an X11 application to monitor keyboard events in the current session. It only works for the current user, and in the current graphical environment, and may not be able to observe privileged dialogs, for example password inputs. For details, look at the application shortcut launcher for your desktop environment; all Linux DEs I've ever heard of have one.

我觉得旧的Linux杂志的文章, Linux的USB输入子系统并的使用输入子系统,仍然是最好的介绍了Linux输入子系统之一。大多数Linux发行时下还支持uinput,即允许注射输入事件回内核子系统,旨在让用户空间的输入设备驱动程序的类似设备。他们在接口 /usr/include/linux/input.h /usr/include/linux/uinput.h 。我建议你​​开始在上面的文章,然后看一些<一个href=\"http://www.thelinuxdaily.com/2010/05/grab-raw-keyboard-input-from-event-device-node-devinputevent/\"相对=nofollow>输入和 uinput 的例子。

I think the old Linux Journal articles, The Linux USB Input Subsystem and Using the Input Subsystem, are still one of the best introductions to the Linux input subsystem. Most Linux distributions nowadays also support uinput, a similar device that allows injecting input events back to the kernel subsystem, designed to allow user-space input device drivers. Their interfaces are described in /usr/include/linux/input.h and /usr/include/linux/uinput.h. I recommend you start at the above articles, and then look at some input and uinput examples.

这篇关于如何在Ubuntu后台进程获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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