title: Python error message 'No error message is available' using win32api
body: <p>There is a script that I made to move the cursor around the screen in Python 2.6. It moves with slight variation along a straight line. The speed is fixed and destination slightly variable as well.</p>
  
  <pre><code>import win32api, random, math
  
  def cmouse(x2,y2):
      x1,y1 = win32api.GetCursorPos()
      x2 = x2 + random.randrange(-1, 2)
      y2 = y2 + random.randrange(-1, 2)
      dis_x = x2-x1
      dis_y = y2-y1
      dis = math.sqrt(math.pow(x2-x1, 2)+math.pow(y2-y1, 2))
      n = int((dis/2200)*100)
      for i in range(0, n+1):
          t = (random.randrange(1, 3)*0.005)
          c1,d1 = win32api.GetCursorPos()
          if c1 in range(x2-45, x2+46) and d1 in range(y2-45, y2+46):
              var_x = 0
              var_y = 0
          else:
              var_x = random.randrange(-3, 4)
              var_y = random.randrange(-3, 4)
          if n!=0:
              win32api.SetCursorPos((int(x1 + var_x + i*(float(dis_x)/n)),
                                     int(y1 + var_y + i*(float(dis_y)/n))))
              time.sleep(t)
          else:
              time.sleep(t)
              break
  </code></pre>
  
  <p>It works well 99.5% of the time, but sometimes I get this error.</p>
  
  <pre><code>File "C:\User\Desktop\Script.py", line 58, in cmouse
      win32api.SetCursorPos((int(x1 + var_x + i*(float(dis_x)/n)),
                             int(y1 + var_y + i*(float(dis_y)/n))))
  error: (0, 'SetCursorPos', 'No error message is available')
  </code></pre>
  
  <p>I can't find any way to fix this rare but annoying error. I'm quite sure it has to do with the win32api, but I am looking for some help.</p>