我该如何获得在bash当前鼠标坐标? [英] How would I get the current mouse coordinates in bash?
本文介绍了我该如何获得在bash当前鼠标坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在bash当前鼠标的坐标和xdotool不为我工作。我会怎么做呢?
I need to get the current mouse coordinates in bash and xdotool does not work for me. How would I do this?
推荐答案
要避免所有的sed / awk的/剪切的东西,你可以用
To avoid all the sed/awk/cut stuff, you can use
xdotool getmouselocation --shell
在具体地,
eval $(xdotool getmouselocation --shell)
将摆放位置到shell变量 X
,是
和屏幕
。在这之后,
echo $X $Y
会给准备以后 xdotool鼠标移动
或任何其他用途的一个片段。
will give a snippet ready for a later xdotool mousemove
or any other use.
我的顺序点击进入了一些额外的位置是一个文件positions.txt(由少数的eval /回声给出运行):
My extra for sequential clicking into a few positions is a file positions.txt (given by a few eval/echo runs):
123 13
423 243
232 989
和使用它的code是:
And the code that uses it is:
while read line; do
X=`echo $line| cut -c1-3`;
Y=`echo $line| cut -c4-7`;
xdotool mousemove --sync $(( 0.5 + $X )) $(( 0.5 + $Y ));
xdotool click 1
done < positions.txt
如果没有必要规模像素(不像我的情况),也可以是一个简单的
If there is no need to scale pixels (unlike my case), it could be a simple
while read line; do
xdotool mousemove --sync $line;
xdotool click 1
done < positions.txt
这篇关于我该如何获得在bash当前鼠标坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文