从bash或python检测当前鼠标光标类型的方法 [英] The way to detect the current mouse cursor type from bash or python

查看:53
本文介绍了从bash或python检测当前鼠标光标类型的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以通过执行"xdotool getmouselocation"来获取鼠标光标的当前位置.

I know that I can get the current location of the mouse cursor by executing "xdotool getmouselocation".

我想从bash终端或python代码中检测当前的鼠标光标类型,例如指针,光束或手形光标.这可能吗?

I would like to detect the current mouse cursor type such as pointer, beam, or hand cursor from bash terminal or python code. Would this be possible?

谢谢.六月

推荐答案

您可以使用xdotool连续单击链接的位置,直到程序注意到窗口标题更改为止.当窗口标题更改时,这意味着已单击链接,并且正在加载新页面.

You can use xdotool to continuously click where the link would be until the program notices the window title changes. When the window title changes, that means the link has been clicked, and the new page is loading.

点击功能:

ff_window=$(xdotool search --all --onlyvisible --pid "$(pgrep firefox)" --name ".+")

click-at-coords() {
    title_before=$(xdotool getwindowname $ff_window)
    while true; do
        sleep 1
        title_now=$(xdotool getwindowname $ff_window)
        if [[ $title_now != $title_before]]; then
            break
        else
            xdotool windowfocus --sync "$ff_window" mousemove --sync "$1" "$2" click 1
        fi
    done
}

假设您使用xdotool来使用坐标单击:

Assuming that you're using xdotool to click using coordinates:

# replace each x and y with the coordinates of each link
# example with 2 sets of coordinates: all_coords=("67 129" "811 364")
all_coords=("x y" "x y")

for sub in "${all_coords[@]}"; do
    coords=($sub)
    click-at-coords "${coords[@]}"
done

这篇关于从bash或python检测当前鼠标光标类型的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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