PDA

View Full Version : set mouse position


AlyssaK
01-27-2009, 08:25 PM
Hi all,

I would like to know if its is possible to set the mouse position???

I found the method viz.mousepos and have assigned it the value of the wiimote coordinates however the cursor does not move.

If you can help please post a response.

ALyssa

farshizzo
01-28-2009, 04:05 PM
The following script shows how to use a wiimote to control the mouse movement and simulate mouse button presses:import viz
import win32api
import win32con

viz.go()

#Create wii extension
wii = viz.add('wiimote.dle')

#Connect to wiimote
wiimote = wii.addWiimote()
if not wiimote.valid():
sys.exit()

#Use wiimote button B to simulate left mouse click
def SimulateMouseButton(button):
win32api.mouse_event(button,0,0,0)
vizact.onsensordown(wiimote,wii.BUTTON_B,SimulateM ouseButton,win32con.MOUSEEVENTF_LEFTDOWN)
vizact.onsensorup(wiimote,wii.BUTTON_B,SimulateMou seButton,win32con.MOUSEEVENTF_LEFTUP)

#Use wiimote IR sensor position to simulate mouse movement
def SimulateMouseMove():
x,y = wiimote.posIR
win32api.mouse_event(win32con.MOUSEEVENTF_ABSOLUTE |win32con.MOUSEEVENTF_MOVE,int(65535*x),int(65535* (1.0-y)),0)
vizact.ontimer(0,SimulateMouseMove)