首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >bfgminer未捕获xdotool

bfgminer未捕获xdotool
EN

Ask Ubuntu用户
提问于 2014-01-05 08:14:09
回答 1查看 232关注 0票数 1

我试图发送一个短序列的按键给bfgminer,而不让它的窗口聚焦,它正在运行在一个侏儒终端。

代码语言:javascript
复制
#! /bin/bash
xdotool key --window 25165831 p
sleep 1
xdotool key --window 25165831 s
sleep 1
xdotool key --window 25165831 0

什么都没发生。尽管当我运行下面的脚本时,它可以工作。

代码语言:javascript
复制
#! /bin/bash
xdotool windowactivate 25165831
sleep 1
xdotool key p
sleep 1
xdotool key s
sleep 1
xdotool key 0

我已经研究过expect了,但是它又大又复杂,我只是在寻找一个简短的简单解决方案。虽然从我所读到的看来,expect可以完成这项工作。如果xdotool在执行我的脚本时与用户交互发生冲突,那么使用expect可能更好。如有任何帮助,将不胜感激!)

EN

回答 1

Ask Ubuntu用户

发布于 2014-08-03 10:03:12

许多程序在没有键盘强制键的情况下不接受键击--这当然是有意义的。

但是您不需要使用“窗口激活”、“窗口焦点”工作,也不需要将窗口放在前面等等:

xdotool windowfocus 8392809 key p

此外,还可以使用sleep命令xdotool将命令简化为一行。

xdotool key p sleep 0.5 key s

或者使用选项--delay和命令key

作为背景:您尝试的命令看起来非常相似,但是有一个技术差异,用man xdotool解释:

代码语言:javascript
复制
SENDEVENT NOTES
    If you are trying to send key input to a specific window, and it does not appear to be working, then it's
    likely your application is ignoring the events xdotool is generating. This is fairly common.

    Sending keystrokes to a specific window uses a different API than simply typing to the active window. If you
    specify 'xdotool type --window 12345 hello' xdotool will generate key events and send them directly to window
    12345.  However, X11 servers will set a special flag on all events generated in this way (see
    XEvent.xany.send_event in X11's manual). Many programs observe this flag and reject these events.

    It is important to note that for key and mouse events, we only use XSendEvent when a specific window is
    targeted. Otherwise, we use XTEST.

    Some programs can be configured to accept events even if they are generated by xdotool. Seek the documentation
    of your application for help.

    Specific application notes (from the author's testing): * Firefox 3 seems to ignore all input when it does not
    have focus.  * xterm can be configured while running with ctrl+leftclick, 'Allow SendEvents' * gnome-terminal
    appears to accept generated input by default.
票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/400363

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档