[BangPypers] moving/clicking the mouse cursor using python
Narendra Sisodiya
narendra at narendrasisodiya.com
Fri Jan 7 12:24:20 CET 2011
On Fri, Jan 7, 2011 at 4:48 PM, Anand Balachandran Pillai
<abpillai at gmail.com> wrote:
> You should be using ncurses for applications like this which need mouse
> positions (x,y) on the console.
>
> http://pyncurses.sourceforge.net/
What will be the difference ? can I use pyncurses to generate global
mousemovement ? like the way i did with xdotool.
Also, What about Windows/Mac Platform ?
>
> Please don't use X like the way you did in the 2nd approach, *nix
> really can do better than that. This ain't 1999 you know.
Thanks for tip, but I never write such code so i am asking.
>
> --Anand
>
> On Fri, Jan 7, 2011 at 4:36 PM, Narendra Sisodiya <
> narendra at narendrasisodiya.com> wrote:
>
>> 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 at python.org
>> http://mail.python.org/mailman/listinfo/bangpypers
>>
>
>
>
> --
> --Anand
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
--
┌─────────────────────────┐
│ Narendra Sisodiya
│ http://narendrasisodiya.com
└─────────────────────────┘
More information about the BangPypers
mailing list