您尚未登录。

#1 2013-05-20 19:51:18

BlueSail
会员
注册时间: 2013-05-20
帖子: 5

[求帮]怎样编写按键宏BASH脚本

怎样编写按键宏,每个按键时间间隔1秒。并可自定义参数,(参数主要用于:比如在命令行运行这个按键宏脚本:

$ auto-macro 21 <return>

然后让它自动执行如下按键组合:

<shift>-c, s, <return>, <tab>, <ctrl>-v, 21, <tab>, <ctrl>-s, <tab>
<shift>-c, s, <return>, <tab>, <ctrl>-v, 20, <tab>, <ctrl>-s, <tab>
.......................
<shift>-c, s, <return>, <tab>, <ctrl>-v, 01, <tab>, <ctrl>-s, <tab>
<shift>-c, s, <return>, <tab>, <ctrl>-v, 00, <tab>, <ctrl>-s, <tab>

如果是:

$ auto-macro 63 <return>

则会按键:

<shift>-c, s, <return>, <tab>, <ctrl>-v, 63, <tab>, <ctrl>-s, <tab>
<shift>-c, s, <return>, <tab>, <ctrl>-v, 62, <tab>, <ctrl>-s, <tab>
...................
<shift>-c, s, <return>, <tab>, <ctrl>-v, 01, <tab>, <ctrl>-s, <tab>
<shift>-c, s, <return>, <tab>, <ctrl>-v, 00, <tab>, <ctrl>-s, <tab>

我的能力还不能写出这样的脚本,望高手指教,同僚探讨!


2012年8月首次使用Arch的社区一员。

离线

#2 2013-05-20 20:07:47

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,463
个人网站

Re: [求帮]怎样编写按键宏BASH脚本

用 xdotool 模拟按键。

离线

#3 2013-05-20 20:14:22

BlueSail
会员
注册时间: 2013-05-20
帖子: 5

Re: [求帮]怎样编写按键宏BASH脚本

百合仙子 说:

用 xdotool 模拟按键。

真是一语值千金啊!谢谢,我正在看 xdotool 的manpage, 看起来它是个很强大又优雅的工具。


2012年8月首次使用Arch的社区一员。

离线

页脚