title: Programmatically control the mouse
body: <p>I've been playing a simple online game where the only thing the user controls is the acceleration of a car. The car goes around the same track every time.</p>
  
  <p>The track has like 6-7 curves, and one lap only takes a few seconds, maybe five. With the left-click of a mouse the car accelerates, releasing it to slow down. If you hit a curve while going too fast, the car goes off the track and you lose time.</p>
  
  <p>Now I, being a human, sometimes hold the button a fraction too long and the car goes off the track, or I do the opposite&mdash;afraid of losing time, I slow down too much. If there was a robot playing instead of me, it could play a very fast time again and again. If I could programme him like "hold the button down for 340 miliseconds, then release for 200 miliseconds, then hold down for 1250 miliseconds" etc., after a few tests I could adjust the timing very accurately and be very hard to beat.</p>
  
  <p>How can I write a program to do this?</p>