Cursor Position.
snoe
case.nelson at gmail.com
Wed Nov 16 13:26:15 EST 2005
This script should be a good start:
from ctypes import *
import time
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),
("time",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()
windll.user32.GetCursorPos(byref(orig))
windll.user32.SetCursorPos(x,y)
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
More information about the Python-list
mailing list