Recently I needed to take a picture of the entire content of a huge scroll view, i.e. a view inside an application of which only a small part was visible on the screen. I was suprised that most available screenshot software couldn‘t do that but would only capture the whole screen, a part of the screen or a window visible on the screen.

MAS Scroll Shot

OS X built-in screenshot services don‘t capture entire scroll views and of the tons of third party screenshot software I only found two applications, Layers and Snagit, capable of capturing the complete content of a scroll view. I‘m not talking about capturing the content of a web browser‘s view (there are many tools and add-ins doing that) but about capturing scroll views of any application running on my Mac, for example in iTunes, Finder or the Mac App Store.

Layers and Snagit are nice but not exactly like I wanted, and they‘re pretty expensive, too (Snagit 49,95 USD, Layers: 24,99 USD, though there‘s the sibling app Layers Shots for 4,99 USD). I also wondered why it seems to be so difficult to capture the content of a scroll view and tried to figure that out. I wanted to know how to get pixel perfect captures of scroll view content, without Lion‘s auto-fade scrollbars annoyingly visible.

The result so far is a working code base producing captures like the one shown above (which is sized down), showing the Mac App Store’s top charts.

This may turn into a new application, working title Scroll Capture, if I decide to go on with this. It would be a simple tool serving a single purpose, capturing scroll view content, as for capturing everything else there are already many applications and tools in place.

Technical Background

It is not obvious how to capture the content of a scroll view of another application running on your Mac, though it is of course possible, even when only using ‘official’ APIs.

To therefore lift at least some of its dark secrets: This all is (only) possible by using the Accessibility API of OS X. It exists to allow applications to make their contents easily accessible, e.g. to users with disabilities, but also to other (assistive) applications which can use the API to access the content. By using the Accessibility API it is possible to locate any scroll view visible on the screen and to tell it to move the visible part of its content up and down, in order to capture the then visible part until all the content is captured in several partial images. All what is left then is to put together a composite image consisting of the several captures of the different parts of the scroll view content.

Unfortunately, accessibility programming on OS X is something not featured in most Cocoa books or online tutorials. It is quite a mess as the frameworks and libraries are a wild mixture of Cocoa and Carbon and there isn‘t any comprehensive documentation. What helped me most to figure it out were Apple‘s sample applications UIElementInspector and Son Of Grab.