博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux模拟键盘按键_Linux上的自动键盘按键
阅读量:2517 次
发布时间:2019-05-11

本文共 3182 字,大约阅读时间需要 10 分钟。

linux模拟键盘按键

Automatic keyboard pressers are useful . However, it seems that there is no simple and easy to use automatic keyboard presser for if you search for “automatic keyboard presser linux”. After some digging, I find using the with some options is a good method for automatic keyboard pressing though it is not designed for this purpose.

自动键盘按下器是有用的 。 但是,如果您搜索“ 自动键盘按键”,似乎没有简单易用的自动键盘按键。 经过一番挖掘后,我发现使用和一些选项是自动按键盘的好方法,尽管它不是为此目的而设计的。

一个例子 (One example )

Let’s use one example here to introduce how to use xvkbd as a automatic keyboard presser: we want to refresh the browser every 5 seconds to check a webpage for changes. If you do it manually, you press Ctrl + r every 5 seconds. Let’s make the computer do it automatically for us while what we need to do is just to watch the screen while drinking a cup of tea.

让我们在这里使用一个示例来介绍如何将xvkbd用作自动键盘xvkbd器:我们希望每5秒刷新一次浏览器以检查网页是否有变化。 如果您手动执行此操作,则每5秒按Ctrl + r 。 让我们让计算机为我们自动完成它,而我们需要做的就是只是在喝杯茶的同时观看屏幕。

xvkbd发送一个字符串 (xvkbd sends a string )

xvkbd has an option -text which can send the string to the focused window:

xvkbd有一个选项-text它可以将字符串发送到焦点窗口:

-text stringSend the string to the focused window (see also `-window' option). If this option is specified, xvkbd will not open its window and terminate soon after sending the string.The string can contain:\r - Return\t - Tab\b - Backspace\e - Escape\d - Delete\S - Shift (modify the next character; please note that modify with ``\S'' will be ignored in many cases. For example, ``a\Cb\ScD\CE'' will be interpreted as a, Control-b, c, Shift-D, and Control-Shift-E.)\C - Control (modify the next character)\A - Alt (modify the next character)\M - Meta (modify the next character)\[keysym] - the keysym keysym (e.g., \[Left]), which will be processed in the similar matter with other general characters\{keysym} - the keysym keysym (e.g., \{Left}), which will be processed in more primitive matter and can also be used for modofier keys such as Control_L, Meta_L, etc.; also, \{+keysym} and \{+keysym} will simulate press and release of the key, respectively \Ddigit - delay digit * 100 ms\xvalue - move mouse pointer (use "+" or "-" for relative motion)\yvalue - move mouse pointer (use "+" or "-" for relative motion)\mdigit - simulate click of the specified mouse button

With this option, we can send out Ctrl + r by:

使用此选项,我们可以通过以下方式发送Ctrl + r

xvkbd -text "\Cr"

脚本为自动按键 (The script as the automatic key presser )

With the option of xvkbd, we can write our own automatic key presser with a bit bash script to repeatedly invoke xvkbd.

使用xvkbd选项,我们可以使用一些bash脚本编写自己的自动按键,以重复调用xvkbd

Here comes the script that automatically refresh the browser (the active window).

这是自动刷新浏览器(活动窗口)的脚本。

while true; do xvkbd -text "\Cr"; sleep 5; done;

Execute it in a , make the browser focused and then you can watch the page “automatically” refreshed.

在执行它,使浏览器聚焦,然后您可以观看“自动”刷新的页面。

When you want to stop the “automatic keyboard presser”, just press Ctrl+c in the shell window.

当您要停止“自动键盘按下器”时,只需在外壳程序窗口中按Ctrl+c

More interesting and complex key pressers can be made using the functions provided by xvkbd (especially the \D to delay a little while).

可以使用xvkbd提供的功能(尤其是\D稍有延迟)来制作更有趣,更复杂的按键。

翻译自:

linux模拟键盘按键

转载地址:http://zoowd.baihongyu.com/

你可能感兴趣的文章
第一章《人造与天生》
查看>>
centos7 install rabbtimq
查看>>
hdu 1002 A+B Problem 2
查看>>
消息队列五
查看>>
Ubuntu 14.04 64bit下Caffe + Cuda6.5/Cuda7.0 安装配置教程
查看>>
js中期知识点总结11月2日
查看>>
20150716 DAY5
查看>>
【C语言及程序设计】生成随机数
查看>>
学习新语言等技能的历程
查看>>
04代理,迭代器
查看>>
解决Nginx+PHP-FPM出现502(Bad Gateway)错误问题
查看>>
Java 虚拟机:互斥同步、锁优化及synchronized和volatile
查看>>
2.python的基本数据类型
查看>>
python学习笔记-day10-01-【 类的扩展: 重写父类,新式类与经典的区别】
查看>>
查看端口被占用情况
查看>>
浅谈css(块级元素、行级元素、盒子模型)
查看>>
Ubuntu菜鸟入门(五)—— 一些编程相关工具
查看>>
Android实现AppWidget、Broadcast动态注册
查看>>
《霸王背单词》功能分析
查看>>
PHP开源搜索引擎
查看>>