WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-13-2013, 02:36 PM
javadi javadi is offline
Member
 
Join Date: Mar 2013
Location: London
Posts: 33
Set Mouse Position

Dear all

In occasions, I need to set the position of the mouse to a certain location in the screen. I noticed that Vizard has some functions for getting mouse position. But I couldn't find anything for setting mouse position. I know that there are other libraries such as ctypes and win32api that you can use for setting the mouse position. I am wondering whether there is anything implemented in Vizard. Very many thanks.

Greetings :-)
Amir
Reply With Quote
  #2  
Old 11-15-2013, 06:04 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Try the following:
Code:
import viz
import win32api
import win32con

viz.go()

x=0.1
y=0.9

win32api.mouse_event(win32con.MOUSEEVENTF_ABSOLUTE|win32con.MOUSEEVENTF_MOVE,int(65535*x),int(65535*(1.0-y)),0)
Reply With Quote
  #3  
Old 11-19-2013, 04:59 AM
javadi javadi is offline
Member
 
Join Date: Mar 2013
Location: London
Posts: 33
Hi Jeff

Very many thanks for the code. What is the difference between your code and simply using the following code as you also use win32api?

win32api.SetCursorPos((int(x), int(y)))

This is a nice piece of code demonstrating it

Code:
import win32api
import time
import math

for i in range(100):
    x = 500+math.sin(math.pi*i/100)*500
    y = 500+math.cos(i)*100
    win32api.SetCursorPos((int(x), int(y)))
    time.sleep(.1)
Greetings
Amir
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse bug in V3 and V4 Renato Lima Vizard 2 05-11-2011 07:38 PM
Mouse event: how to detect no mouse move event, how to set mouse position? Zhi Vizard 3 04-11-2011 07:25 PM
how to remove velocity when mouse is disabled? jvacare1 Vizard 2 02-18-2010 11:25 AM
Navigating an avatar using mouse position(2D) in 3D environment james007 Vizard 1 10-16-2009 12:29 PM
set mouse position AlyssaK Vizard 1 01-28-2009 05:05 PM


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


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