WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   set mouse position (https://forum.worldviz.com/showthread.php?t=1792)

AlyssaK 01-27-2009 08:25 PM

set mouse position
 
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:
Code:

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,SimulateMouseButton,win32con.MOUSEEVENTF_LEFTDOWN)
vizact.onsensorup(wiimote,wii.BUTTON_B,SimulateMouseButton,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)



All times are GMT -7. The time now is 10:20 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC