xdotool - 为什么睡眠运行命令之前? [英] xdotool - Why sleep before running commands?

查看:189
本文介绍了xdotool - 为什么睡眠运行命令之前?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 xdotool 来自动运行命令,打开新的标签页等。

I'm using xdotool to automate running commands, opening new tabs, etc.

问题是当前窗口做时,我已经专门睡一段时间,或做任何事情,否则<$ C $之前使用 xdotool KEYUP返回 C> xdotool 不会preSS回车键。

The thing is when doing it on the current window, I've to specifically sleep for some time or use xdotool keyup Return before doing anything or else xdotool won't press the enter key.

kartik@kartikpc:~/junk/xdotool$ cat automate 
#!/bin/bash

# Release the Return key
# xdotool keyup Return
# Or sleep 1

xdotool type --delay 1 --clearmodifiers "clear"
xdotool key --clearmodifiers Return

kartik@kartikpc:~/junk/xdotool$ source automate 
clearkartik@kartik-lappy:~/junk/xdotool$ clear

我已经从很少的来源是阅读

What I've read from very few sources is

%睡眠1; xdotool键入$(printf的你好\\ nworld \\ n)(睡眠是
  让我释放打字之前我实际的回归键)

% sleep 1; xdotool type "$(printf "hello\nworld\n")" (the sleep is for letting me release my actual 'return' key before typing)

据我所知,'回报'关键是pressed时我特意在键盘上pressingEnter键调用我的脚本。但是,为什么是不是自动释放?

I understand that the 'return' key is pressed when I specifically invoke my script by pressing 'Enter' on the keyboard. But why isn't it released automatically?

即使 xdotool 使用 xdotool类型输入的东西应该不是'返回'键释放到那时或每信应该已持续的,而不是在同一行未来行后线,

Even when xdotool is typing stuff using xdotool type shouldn't the 'return' key release till that time, or every letter should have been going line after line, instead of coming on the same line

推荐答案

这个问题更多的是与键盘本身不是任何专用的操作系统概念的状态。如果键只说是pressed当它从上到下的状态过渡。

The issue has more to do with the state of the keyboard itself than any special OS concepts. If key is only said to be "pressed" when it transitions from the "up" to "down" states.

当应用程序试图发送一个关键preSS,它将发送的keydown后跟一个KEYUP。如果关键是已经处于下降状态,发送的keydown不会注册为重点preSS因为键的状态并没有从上到下过渡,它仅仅停留在向下状态。 (在下来的状态发送的keydown,而已经等同于简单地按住按键后,没有pressing它另一次。)

When an application tries to send a keypress, it will send a keydown followed by a keyup. If the key is already in the "down" state, sending a keydown won't register as a key press because the key's state didn't transition from "up" to "down", it merely stayed in the "down" state. (Sending a keydown while already in a "down" state is equivalent to simply holding the key down, not pressing it another time.)

这篇关于xdotool - 为什么睡眠运行命令之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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