bash 如何在linux bash中模拟按箭头键

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40919985/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 15:29:38  来源:igfitidea点击:

how to simulate pressing an arrow key in linux bash

linuxbashshell

提问by mysticalstick

I've worked with powershell before but I'm new to linux bash scripts. Say I wanted to write a script that just presses a key (left arrow) in regular intervals (0.05s). How could I go about doing this?

我以前使用过 powershell,但我是 linux bash 脚本的新手。假设我想编写一个脚本,只需按固定时间间隔(0.05 秒)按下一个键(向左箭头)。我怎么能去做这件事?

采纳答案by T. Kropalis

Use Xdotool. Its usage is:

使用Xdotool。它的用法是:

xdotool key SPECIFY_KEY

and replace SPECIFY_KEY with the required keystroke,
or in yourcase:

并将 SPECIFY_KEY 替换为所需的按键,
或者在您的情况下:

xdotool key Up/Down/etc.