title: BASH XDOTool Mouse click, repeat and stop
body: <p>I am trying to integrate a simple infinite click script using XDOToool with another piece of script to detect keyboard input; to end the running clicking script when a key is pressed but unsure how to match them up.</p>
  
  <p>This script runs infinitely repetitively clicking at screen cursor point XXX, YYY determined by XDOTool</p>
  
  <pre><code> #!/bin/bash
   while true [ 1 ]; do
   xdotool mousemove XXX YYY click 1 &amp;
   sleep 1.5
   done
  </code></pre>
  
  <p>Next I wish to use something like:</p>
  
  <pre><code>#!/bin/bash
  if [ -t 0 ]; then stty -echo -icanon -icrnl time 0 min 0; fi
  count=0
  keypress=''
  while [ "x$keypress" = "x" ]; do
  let count+=1
  echo -ne $count'\r'
  keypress="`cat -v`"
  done
  if [ -t 0 ]; then stty sane; fi
  echo "You pressed '$keypress' after $count loop iterations"
  echo "Thanks for using this script."
  exit 0
  </code></pre>
  
  <p>I don't understand how I take the:</p>
  
  <pre><code> xdotool mousemove XXX YYY click 1 &amp;
   sleep 1.5
  </code></pre>
  
  <p>And where to put it in the script above, BASH confusion and MAN BASH doesn't help so anyone who could assist would be appreciated. THANKS</p>