WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Overriding Mouse Control (https://forum.worldviz.com/showthread.php?t=426)

Vygreif 09-28-2005 04:36 PM

Overriding Mouse Control
 
Hi,
I want to manually set the location of the mouse cursor and use some other sort of input to control where the cursor is. How do I do that?

Thanks,
Vygreif

farshizzo 09-28-2005 05:05 PM

Hi,

The following script will manually move the mouse in a circlular motion at the center of the screen. The command to move the mouse cursor is win32api.mouse_event:
Code:

import viz
viz.go(viz.FULLSCREEN)

import win32api
import math

angle = 0

def ontimer(num):
        global angle
        angle += 90 * viz.elapsed()
        x = (math.sin(viz.radians(angle)) * 0.3) + 0.5
        y = (math.cos(viz.radians(angle)) * 0.3) + 0.5
        x = int(65535*x)
        y = int(65535*y)
       
        #The mouse coordinates must be normalized from 0 to 65535.
        #The origin (0,0) represents the upper left corner of the monitor
        win32api.mouse_event(32769,x,y,0)
       
viz.callback(viz.TIMER_EVENT,ontimer)
viz.starttimer(0,0,viz.FOREVER)


Vygreif 09-28-2005 07:34 PM

Looks good.
But where can I get win32api, when I try including it, it can't find the module.

farshizzo 09-28-2005 08:51 PM

Hi,

It's included in version 2.53 and above. If you don't want to upgrade send an email to lashkari@worldviz.com and I will send it directly to you.


All times are GMT -7. The time now is 11:00 PM.

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