[Tutor] Apple Remote "Mouse"

Alan Gauld ukc802591034 at btconnect.com
Sat Apr 1 23:28:44 CEST 2006


"Johnston Jiaa" <artificiallystupid at yahoo.com> wrote in message
> I recently bought a Macbook Pro from Apple.

I'm jealous already...

> As it comes with a remote, I thought it would be great to use it as
> a mouse when not in Front Row.  ...
> Is there any way to manipulate the cursor position on the screen using 
> Python?

This is really about programming Cocoa more than it is about Python.
You need to look at how you would do this in Objective C first then
translate that to Python using the Cocoa wrappers for MacPython.

It should all be feasible but I'd start looking on the Apple development
sites first - have you checked the fantastic programmer's pages on the
Apple site at:

http://developer.apple.com/

If you haven't already done so sogn up to the developers email list.
Not only do you get advance news of developments in Apple land
but they post new articles and how-tos every week or so.

Also worth keeping an eye on is O'Reilly's MacDevCenter

http://www.macdevcenter.com/

And finally Stepwise's Vermont recipes are great:

http://www.stepwise.com/

Look in particular at the starting Cocoa and Articles links.

For your purpose you will need to create mouse events and then
post them to the applications event queue using the postEvent
method. There are several factory methods available for creating events.

Warning: This is not a trivial task and will involve some fairly deep
reading about the Apple event model and the mouse event definitions
in particular. But it is doable.

HTH,


-- 
Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld






More information about the Tutor mailing list