Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38383 > unrolled thread

Moving mouse, Python3 and PyObjc

Started byjoaofguiomar@gmail.com
First post2013-02-07 15:22 -0800
Last post2013-02-08 02:24 -0800
Articles 7 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  Moving mouse, Python3 and PyObjc joaofguiomar@gmail.com - 2013-02-07 15:22 -0800
    Re: Moving mouse, Python3 and PyObjc Terry Reedy <tjreedy@udel.edu> - 2013-02-07 19:51 -0500
    Re: Moving mouse, Python3 and PyObjc Dave Angel <davea@davea.name> - 2013-02-07 21:08 -0500
      Re: Moving mouse, Python3 and PyObjc Oneill <joaofguiomar@gmail.com> - 2013-02-08 02:32 -0800
        Re: Moving mouse, Python3 and PyObjc Dave Angel <davea@davea.name> - 2013-02-08 09:36 -0500
      Re: Moving mouse, Python3 and PyObjc Oneill <joaofguiomar@gmail.com> - 2013-02-08 02:32 -0800
    Re: Moving mouse, Python3 and PyObjc Oneill <joaofguiomar@gmail.com> - 2013-02-08 02:24 -0800

#38383 — Moving mouse, Python3 and PyObjc

Fromjoaofguiomar@gmail.com
Date2013-02-07 15:22 -0800
SubjectMoving mouse, Python3 and PyObjc
Message-ID<da8d9786-1e39-44c0-80af-14dab2327074@googlegroups.com>
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.

[toc] | [next] | [standalone]


#38388

FromTerry Reedy <tjreedy@udel.edu>
Date2013-02-07 19:51 -0500
Message-ID<mailman.1462.1360284710.2939.python-list@python.org>
In reply to#38383
On 2/7/2013 6:22 PM, joaofguiomar@gmail.com wrote:
>
> 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.

If the import fails, then the call to clickMouse should fail with 
NameError, but you said that clickMouse executes, so it is hard to 
determine what you have done and what does and does not work.

You need to post more information.

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


#38394

FromDave Angel <davea@davea.name>
Date2013-02-07 21:08 -0500
Message-ID<mailman.1468.1360289355.2939.python-list@python.org>
In reply to#38383
On 02/07/2013 06:22 PM, joaofguiomar@gmail.com wrote:
>
> 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

[toc] | [prev] | [next] | [standalone]


#38437

FromOneill <joaofguiomar@gmail.com>
Date2013-02-08 02:32 -0800
Message-ID<c4204f6f-af7f-4651-825b-cc50e48bf12b@googlegroups.com>
In reply to#38394
> 
> >
> 
> > 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.

[toc] | [prev] | [next] | [standalone]


#38452

FromDave Angel <davea@davea.name>
Date2013-02-08 09:36 -0500
Message-ID<mailman.1502.1360334202.2939.python-list@python.org>
In reply to#38437
On 02/08/2013 05:32 AM, Oneill wrote:
>
>>

Your emails are very hard to read, since your mailer doublespaces nearly 
everything you quote.

>>>  <snip>
>>
>>
>> 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...

Well, now I can guess some of the answers to my questions.  You 
mentioned Windows, but apparently that was a red herring.  You are 
apparently writing an objective C application (Cocoa) for the iPhone, 
and using the pyobjc module to translate Python to Objective C.

so the answer to your original problem (mouse going to 0,0) could need 
some combination of Mac development tools, Cocoa runtime environment, 
etc. to solve.  You're not writing cross-platform, so you've rejected 
the standard guis for doing this sort of thing.

Perhaps the page at
     http://docs.python-guide.org/en/latest/scenarios/gui/

could be of help in choosing a different gui toolkit.

But I can't figure I'd be of any help, since I don't have a Mac, nor a 
license for their development environment, nor any docs for either.



-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#38438

FromOneill <joaofguiomar@gmail.com>
Date2013-02-08 02:32 -0800
Message-ID<mailman.1496.1360320059.2939.python-list@python.org>
In reply to#38394
> 
> >
> 
> > 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.

[toc] | [prev] | [next] | [standalone]


#38436

FromOneill <joaofguiomar@gmail.com>
Date2013-02-08 02:24 -0800
Message-ID<bc5ae9d5-f776-414c-8db3-2b55ceedcc9a@googlegroups.com>
In reply to#38383
On Thursday, 7 February 2013 23:22:01 UTC, Oneill  wrote:
> 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.




Well i did this : sudo env CC=clang easy_install -U pyobjc

and i get alot of these: 

warning: no directories found matching 'source-deps'
warning: no previously-included files matching '.DS_Store' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.so' found anywhere in distribution
clang: warning: argument unused during compilation: '-mno-fused-madd'
Skipping installation of build/bdist.macosx-10.8-intel/egg/PyObjCTest/__init__.py (namespace package)
Skipping installation of build/bdist.macosx-10.8-intel/egg/PyObjCTest/test_abactions.py (namespace package)

before i tried easy_install pyobjc and it failed, with  env CC=clang it finishes but with alot of those warnings.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web