在bash脚本中检测鼠标单击 [英] Detect mouse click in bash script

查看:57
本文介绍了在bash脚本中检测鼠标单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在后台运行bash脚本,该脚本将在用户单击鼠标时执行某些操作(即运行脚本,命令或其他命令).我希望即使终端关闭,它也可以继续运行.有任何想法吗?谢谢!

I'm wondering how to run a bash script in the background that will do something (i.e. run a script, or a command, or whatever) whenever a user clicks the mouse. I'd like this to continue running even if the terminal is closed. Any ideas? Thanks!

推荐答案

如果您使用的是X11,则可以尝试 xdotool 捕获鼠标事件

If you are using X11, you can try xdotool to catch mouse events

那会是这样的:

xdotool search --onlyvisible . behave %@ mouse-click getmouselocation

xdotool手册

如果要在后台运行脚本,可以使用:

If you want to run the script in background you can use:

./myscript.sh &>/dev/null &

这篇关于在bash脚本中检测鼠标单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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