Skip to content

Instantly share code, notes, and snippets.

@lpenz lpenz/winclick
Created Nov 17, 2016

Embed
What would you like to do?
Click a window selected by name; uses xwininfo and xdotool
#!/bin/bash
WINNAME="${1?usage: "$0" windowname}"
set -e
TMP=$(mktemp)
trap 'rm -f $TMP' EXIT
eval "$(xdotool getmouselocation --shell)"
xwininfo -name "$WINNAME" > "$TMP"
win_x=$(sed -n 's@Absolute upper-left X:\s*\([0-9]\+\)$@\1@p' "$TMP")
win_y=$(sed -n 's@Absolute upper-left Y:\s*\([0-9]\+\)$@\1@p' "$TMP")
xdotool mousemove $((win_x+10)) $((win_y+10))
xdotool click 1
xdotool mousemove "$X" "$Y"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.