Skip to content

Instantly share code, notes, and snippets.

@mauricioprado00
Created July 19, 2017 13:23
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 mauricioprado00/30f3375a9dbcab7801fb66b8f37ae0a2 to your computer and use it in GitHub Desktop.
Save mauricioprado00/30f3375a9dbcab7801fb66b8f37ae0a2 to your computer and use it in GitHub Desktop.
show from source for phpstorm in ubuntu
#!/usr/bin/env bash
# requires: imagemagik, xdotool, xwininfo
window_id=$(xwininfo -tree -root | grep 'PhpStorm 2016.2.2' | awk '{print $1}')
window_x=$(xwininfo -id $window_id | grep 'Absolute upper-left X' | awk '{print $NF}')
window_y=$(xwininfo -id $window_id | grep 'Absolute upper-left Y' | awk '{print $NF}')
import -window $window_id /tmp/screenshot.jpg
convert -crop 250x40+200+45 /tmp/screenshot.jpg /tmp/toolbar.jpg
position=$(compare -metric RMSE -subimage-search /tmp/toolbar.jpg ~/show-from-source.jpg similarity.jpg 2>&1 | awk '{print $NF}')
rel_x=$(echo $position | awk -F ',' '{print $1}')
rel_y=$(echo $position | awk -F ',' '{print $2}')
abs_x=$(($window_x + $rel_x + 200))
abs_y=$(($window_y + $rel_y + 45))
xdotool mousemove $abs_x $abs_y click 1
sleep 0.3
xdotool click 1
@mauricioprado00
Copy link
Author

could also use

click-by-image ~/show-from-source.jpg 'PhpStorm 2016.2.2' 200 45 250 40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment