In my application, I need to move mouse-pointer and generate click event. I
am not making any GUI application. mouse and click event will be trigger on
dekstop.
Quick and dirty way to do this


import os
def move_mouse(x,y):
    os.system('xdotool mousemove ' + str(x) + ' ' + str(y))
def leftclick():
    os.system('xdotool click 1')
def rightclick():
    os.system('xdotool click 3')


Do anybody know better solution, I want to make a cross platform
application.
I also found some way do it using C library like this

from ctypes import cdll
def move_mouse1(x,y):
    dll = cdll.LoadLibrary('libX11.so')
    d = dll.XOpenDisplay(None)
    root = dll.XDefaultRootWindow(d)
    dll.XWarpPointer(d,None,root,0,0,0,0,x,y)
    dll.XCloseDisplay(d)


But still i am searching for better way.. If anybody know, let me know


-- 
┌─────────────────────────┐
│    Narendra Sisodiya
│    http://narendrasisodiya.com
└─────────────────────────┘
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to