2

I'm trying to use this Python code:

import math
import win32api
for i in xrange(500):
    x = 500 + math.sin(math.pi * i / 100) * 500
    y = 500 + math.cos(i) * 100
    x, y = int(x), int(y)
    win32api.SetCursorPos((x, y))
    time.sleep(.01)

taken from here to move the mouse cursor in an XP VirtualBox. The mouse icon will flicker to the appropriate graphic (when it hits the edge of a window it turns into the <-> resize image, for instance), but it doesn't actually move the visible cursor. I can move the mouse around while the code is running. Same result using the ctypes example in the above link. It works fine in the Win7 host.

I have Guest Additions installed, if that matters.

Community
  • 1
  • 1
wes
  • 1,577
  • 1
  • 14
  • 32

1 Answers1

0

It looks like you forgot to import the win32api.

rubytiger1
  • 78
  • 7
  • 2
    The `import` was probably just left out of the example code -- if that was the problem it wouldn't run at all giving a `NameError: name 'win32api' is not defined` instead. – martineau Dec 26 '10 at 10:00