如何RNG和延迟bash脚本,按RETURN来输入自动打字机脚本

问题描述 投票:0回答:1

当前,我正在使用bash脚本,该脚本会自动键入一个短语,但是我想知道如何将睡眠计数器RNG转换为例如1800-1900秒。如果可能的话,我也想知道如何使脚本延迟按RETURN键。谢谢。

这是脚本

#!/usr/bin/env bash
function autotype_loop()  {
xdotool key space
xdotool type "Text here"
xdotool key Return
sleep 1810
autotype_loop
}
autotype_loop
bash random delay xdotool
1个回答
0
投票

此用例有一个内置变量:

'RANDOM'
     Each time this parameter is referenced, a random integer between 0
     and 32767 is generated.

如果您想在1800-1900之间生成随机变量x,则可以使用算术表达式:

x=$(( 1800 + $RANDOM * 100 / 32767 ))
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.