Skip to content

Instantly share code, notes, and snippets.

@lpenz
Created November 17, 2016 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpenz/1e47c40e8638a7924dab10d061e1da0f to your computer and use it in GitHub Desktop.
Save lpenz/1e47c40e8638a7924dab10d061e1da0f to your computer and use it in GitHub Desktop.
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