WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 02-15-2011, 12:58 AM
Albert Russel Albert Russel is offline
Join Date: Jun 2009
Location: Nijmegen, the Netherlands
Posts: 3
Mouse pointer problem


In one of my programs I want a DropList to appear during a run and choose an item and then hide the list and the mouse pointer again. It all works fine except that the mouse will not go away until I move it after I disabled it. I tried viz.sendEvent(viz.MOUSE_MOVE_EVENT) to simulate a mouse movement but the pointer only disappears after a real mouse movement. Is it possible to hide the mouse without physically moving it?

Thanks in advance, Albert

import viz
import vizshape 



def enableMouse():

def disableMouse():

drop = viz.addDropList()
drop.setPosition(0.5, 0.5)
drop.addItems(["a", "b", "c"])


def handleKey(key):
	global drop
	if key == 'x':
	elif key == 'y':
		viz.sendEvent(viz.MOUSE_MOVE_EVENT) # does not work, I must move the real mouse to make the pointer go away

viz.callback(viz.KEYBOARD_EVENT, handleKey)
Reply With Quote
Old 02-18-2011, 11:22 PM
hosier hosier is offline
Join Date: Feb 2007
Posts: 31
I ran into a similar issue a few years ago. What I came up with is show below. I found this function that acts as if the mouse has been moved and the left button clicked.

from ctypes import *
import time, win32con, win32gui

PUL = POINTER(c_ulong)

class KeyBdInput(Structure):
    _fields_ = [("wVk", c_ushort),
    ("wScan", c_ushort),
    ("dwFlags", c_ulong),
    ("time", c_ulong),
    ("dwExtraInfo", PUL)]

class HardwareInput(Structure):
    _fields_ = [("uMsg", c_ulong),
    ("wParamL", c_short),
    ("wParamH", c_ushort)]

class MouseInput(Structure):
    _fields_ = [("dx", c_long),
    ("dy", c_long),
    ("mouseData", c_ulong),
    ("dwFlags", c_ulong),
    ("dwExtraInfo", PUL)]

class Input_I(Union):
    _fields_ = [("ki", KeyBdInput),
    ("mi", MouseInput),
    ("hi", HardwareInput)]

class Input(Structure):
    _fields_ = [("type", c_ulong),
    ("ii", Input_I)]

class POINT(Structure):
    _fields_ = [("x", c_ulong),
    ("y", c_ulong)]

def click(x,y):
    orig = POINT()
    FInputs = Input * 2
    extra = c_ulong(0)
    ii_ = Input_I()
    ii_.mi = MouseInput( 0, 0, 0, 2, 0, pointer(extra) )
    ii2_ = Input_I()
    ii2_.mi = MouseInput( 0, 0, 0, 4, 0, pointer(extra) )
    x = FInputs( ( 0, ii_ ), ( 0, ii2_ ) )
    windll.user32.SendInput(2, pointer(x), sizeof(x[0]))
    return orig.x, orig.y
You can then call the function like:


and it's like you clicked it at the location x=1,y=1.

For me, the mouse click was actually more important than moving the mouse, so I ended up modifying the the code so that instead of moving the mouse to the passed x and y, I just kept it at the same point and performed the mouse click.

Reply With Quote
Old 02-21-2011, 01:10 AM
Albert Russel Albert Russel is offline
Join Date: Jun 2009
Location: Nijmegen, the Netherlands
Posts: 3
Thanks Aaron, windll.user32.SetCursorPos(x,y) solved my problem.
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
viz.STEREO mouse problem moneim230 Vizard 0 12-05-2010 12:32 AM
mouse pointer shahramy Vizard 3 09-07-2010 02:22 PM
Laser Pointer Question (Again) Elittdogg Vizard 5 09-08-2009 12:02 PM
how to make the mouse pointer pain... yak Vizard 0 05-30-2009 07:05 PM
Mouse problem steve Vizard 7 07-14-2005 03:01 PM

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

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