Accessibility for The Rest Of Us

Saturday, January 26th, 2008

So, in addition to giving you an update on Google Importer, it is about time for another Cocoa post.

Google(Web) Importer for Leopard makes extensive use of the Accessibility API. This may seem a bit weird. Most people would think it would be for things like screen readers and speech recognition, but it can be used for a lot more. For example, the Watch Me Do feature in Automator that lets you record and replay every action you do in an application uses the Accessibility API. Google(Web) Importer will use it to get the search terms from Spotlight and the Finder.

The Accessibility API is great for getting the state of the GUI, such as the location of the mouse, the text typed into a field, or the button a user clicks. It is also great for controlling the GUI, like actually clicking a button or entering text. So, it can really be used in a lot of applications.

(By the way, the front end to the Accessibility API in Applescript is called UI Scripting. Same idea.)

Also, unlike Input Managers (which Google Importer for Tiger used), using the Accessibility API:

  • Is fully supported and documented
  • Works with practically every application (not just Cocoa apps)
  • Should not break between releases, if coded carefully

Now, I don’t think it is necessary to write about how to use the API. It is a C API, but just read the documentation and look at this sample code that demonstrates just about everything.

Instead, I will focus on something else that probably will be purely for the benefit of the mighty search engines…

Aside from being really useful, the Accessibility API is also really powerful and therefore subject to abuse. For example, one could very easily write a keylogger with it. That is probably why Apple decided to disable it by default. To enable it, the user has to open System Prefrences, click on Universal Access, and check the box labeled “Enable access for assistive devices.” Now, there are a couple problems with that approach:

  • It enables access system wide (or user wide, I’m not sure). That means that any application can use it if that little box is checked. In the keylogger example, if the user checked that box to let Automator use it legitimately, the keylogger can also use it without any sort of notification to the user.
  • It is annoying. A user should not be asked to change their preferences just to run your application.

So, Apple came up with another solution in Tiger that solves these problems: the magic function AXMakeProcessTrusted. That will enable the API just for your application and needs to be called from a process running as root, so it is secure. It is also all automatic, so aside from asking the user for his/her password, there is nothing the user needs to do.
The problem is that it seems no one uses it. Every third party application I have seen and even Automator just asks the user to manually check the box in System Preferences. It is more work to implement and has one huge undocumented bug (the application must be relaunched before it is actually trusted Update: reported as #5711990), but I really think people should be using it. So, I thought I would release the code to make it easy to implement it in your app. It includes a helper agent that you should be able to just drop into your project.

Download TrustMe

Google Importer. Is it vaperware? Find out at 11.

Saturday, January 26th, 2008

Yeah, so about this Google Importer for Leopard business.

I am done with college apps and I am now officially a second semester senior! Theoretically, that means more time for programming.
I have started working on it, and it seems to be progressing nicely. Once it is done, I plan to make it completely open source and hopefully have a plugin architecture so developers can make it search information from any website. I am also planning on dropping Google and switching to Yahoo, since they have a much more powerful API (that also means Google Importer will be renamed to something like Web Importer).

So, unfortunately I still cannot tell you when it will be done. I would really appreciate it if people would let me know if they like the path I am taking. If there is a lot of interest for just getting something out, I would be willing to rush a release that has none of these new features, but works on Leopard. Send pleas and candy-flavored bribes to support [at] caffeinatedcocoa[dot]com, or post a comment below.

Hurrays For Winter Break!

Friday, January 4th, 2008

So, I released PhotoBook 1.1 today. 

That’s right, I finally got some time away from school, college apps, and friends (ha) to code! This release has a few major new features, a bunch of little changes of additions, and a whole lot of bug fixes. Most notably, you can now open almost any Facebook photo or album URL in PhotoBook, and I redesigned the photo viewing window to add easier to use slideshow controls. 

The vast majority of changes in this release were based on suggestions from users like you. So, keep sending me your ideas to support  at caffeinatedcocoa dot com. 

I know a lot of people have been asking about Google Importer for Leopard. I have started working on it, but unfortunately it requires a complete rewrite and Apple didn’t add in a nice API to make it easy. You should be learning more about the project soon. 

By the way, I got an iPod Touch and it is incredible. I can’t wait until February when Apple opens it up to developers. I’m hoping that means all developers, including starving (pre-)college students.  If so, I think PhotoBook Mobile or whatever would be really cool. Let me know what you think.