Previous Thread  Next Thread

chat icon How to set mouse position?

lukasbalaz

Posted: Mon Nov 05, 2012 4:41 pm
Joined: 05 Nov 2012
Posts: 4
I use Blender 2.64a and I need set mouse position and I don't know it.
Can you help me, please?

(Sorry for my English. I'm Slovak)
Reply with quote


Jarmade

Posted: Mon Nov 05, 2012 6:13 pm
Joined: 03 Nov 2012
Posts: 4
Not sure if blender has a built in way to do this, but this example only works on windows:

Code:
import bpy
from ctypes import *

# point structure definition
class POINT(Structure):
   _fields_ = [("x", c_ulong), ("y", c_ulong)]

# Gets cursor position (windows only)
def getCursorPos():
   pt = POINT()
   windll.user32.GetCursorPos(byref(pt))
   return pt.x, pt.y

# Sets cursor position (windows only)
def setCursorPos(x, y):
   windll.user32.SetCursorPos(x, y)

# example
x, y = getCursorPos()
setCursorPos(x + 100, y)
Reply with quote


lukasbalaz

Posted: Tue Nov 06, 2012 1:57 pm
Joined: 05 Nov 2012
Posts: 4
I'm beginner python programmer and I don't know how to use Blender engine, too.
Can you write how to run this example, please?

Thanks.
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group