Skip to content

Instantly share code, notes, and snippets.

@eirikb eirikb/
Last active Jan 28, 2017

What would you like to do?
Demo of


##About The demo is meant to show how to make an automated answer to a hn comment, translated from Norwegian to English with these steps:

  1. Click on Chrome address bar.
  2. Type and press enter.
  3. Click on input field.
  4. Type the text for translation and wait for it to translate.
  5. Click "Copy"-button to copy text to clipboard.
  6. Open new tab.
  7. Type hn comment url and press enter.
  8. Click on input field.
  9. Paste translated text.







function click {
scrot out.png
pos=$(findimage out.png $1)
x=$(echo $pos | grep -oP "\d+:" | grep -oP "\d+")
y=$(echo $pos | grep -oP ":\d+" | grep -oP "\d+")
size=$(file $1)
width=$(echo $size | grep -oP "\d+ x" | grep -oP "\d+")
height=$(echo $size | grep -oP "x \d+" | grep -oP "\d+")
x=$(expr $x + $width / 2)
y=$(expr $y + $height / 2)
echo "click $x $y"
xdotool mousemove $x $y click 1
click 1.png
xdotool type ""
xdotool key KP_Enter
sleep 2s
click 2.png
sleep 1s
xdotool type "Absolutt, det burde være ganske enkelt."
sleep 1s
click 3.png
sleep 1s
click 4.png
sleep 1s
xdotool type ""
xdotool key KP_Enter
sleep 1s
click 5.png
xdotool type "$(xclip -o -selection clipboard)"
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.