Moving mouse, Python3 and PyObjc

Oneill joaofguiomar at gmail.com
Fri Feb 8 11:32:15 CET 2013


> 
> >
> 
> > import objc
> 
> >
> 
> > def clickMouse(x, y, button):
> 
> >      bndl = objc.loadBundle('CoreGraphics', globals(), '/System/Library/Frameworks/ApplicationServices.framework')
> 
> >      objc.loadBundleFunctions(bndl, globals(), [('CGPostMouseEvent', 'v{CGPoint=ff}III')])
> 
> >      CGPostMouseEvent((x, y), 1, button, 1)
> 
> >      CGPostMouseEvent((x, y), 1, button, 0)
> 
> >
> 
> > clickMouse(600,500, 1)
> 
> >
> 
> >
> 
> > this seems to send the mouse cursos to the top left corner, no matter what coords i send on clickMouse...
> 
> >
> 
> >
> 
> > Also, I just can't seem to install PyObjc and use it on Python3.3 ... always get No module named objc.
> 
> >
> 
> > Sighs... Made a simple python app while at work (windows 7) and was trying to change it to work on Os X (home computer) but cant even get the basics done (move and click mouse)....
> 
> >
> 
> >
> 
> > Thank you.
> 
> >
> 
> 
> 
> What's the objc module got to do with the mouse?
> 
> 
> 
>      http://packages.python.org/pyobjc/api/module-objc.html
> 
> 
> 
> Perhaps you meant some other module.  Could you be specific?  What 
> 
> modules did you import, what other code did you write, what version of 
> 
> Python are you running, and on which computer OS did you get the results 
> 
> you describe?
> 
> 
> 
> -- 
> 
> DaveA



Well without PyObjc i couldnt control the mouse... I saw some examples importing Quartz  but that also failed...

I have python 2.7 installed and 3.3. I started building the app using Python 3.3 at work (windows) and importing win32api and win32con. Everything went smoothly.

At home I was going to import OS X libs to replace the win32 ones to control the mouse in OS X. I tried installing autopy and it fails

"clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
src/screengrab.c:48:26: warning: implicit declaration of function 'CGDisplayBitsPerPixel' is invalid in C99 [-Wimplicit-function-declaration]
        bitsPerPixel = (uint8_t)CGDisplayBitsPerPixel(displayID);
                                ^
src/screengrab.c:191:2: warning: 'CGLSetFullScreen' is deprecated [-Wdeprecated-declarations]
        CGLSetFullScreen(glContext);
"


PyObjc used to ouput similar errors but i tried with the env CC=clang and at least it doesnt fail, but gives me alot of skipping and warnings.


also tried PyMouse but that didn't work also, couldnt install.



At the moment I can click the mouse and it actually moves, but no matter what coords I place it always goes to the upper left corner.


Mac Os X 10.8.2
Python 2.7 / 3.3
Im using Komodo Edit

also installed ActivstatePython.




More information about the Python-list mailing list