Tag Archive 'screenshot'

May 16 2008

Login Screenshot Challenge - Part 3

Published by john under System

As explained on the previous post, no doubt there is a means to capture a screenshot of the login screen, including all available user names. The question is, how to get there from here? Brett on the Cocoa developer mailing list provided a link to OpenGLScreenSnapshot, which is a Mac OS X application that demonstrates how to use OpenGL to grab a snaphost of the screen and save it to an image.

The example is an Xcode project which is easily imported and ran from with Xcode. The only problem is that the short example uses a menu to invoke the screencapture, so there is no means to logout and invoke the application.

I imagine the code change to make this an application that can be run from a terminal (at which point it could be run in the background using sleep) is trivial. However, problem is, I haven’t spent any time working with Xcode so it may take some time to figure this out.

Needless to say, it’s been an interesting challenge to try and capture the login screen. As I mentioned before, I think we’re 99% of the way there and if anyone can take the above example and make a command line version of the application, who knows, maybe that will bring this thing full circle.

It’s been a great diversion. So what’s the next challenge we can take on ?

Technorati Tags: ,

6 responses so far

May 14 2008

Login Screenshot Challenge - Part 2

Published by john under System

In Part 1 of this series I described my attempts to get a screenshot of the login screen on Mac OS X. The attempts included using hotkeys, Grab application, fast user switching and putting the system to sleep and using the terminal utility ’screencapture.’ All to no avail. The real challenge at hand is that I am looking to accomplish this feat from just one Mac system.

There were several ideas shared by others, including using cron, apple remote desktop and ssh. Again, good intentions, however, no luck.

I was able to dig up one approach that get that gets us 99% of the way there. From a terminal, I can enter the following, where I specify the login name using the switchToUserID parameter:

/System/Library/CoreServices/”Menu Extras”/User.menu/Contents/Resources/CGSession -switchToUserID `id -u root`.

The last parameter `id -u root` uses the terminal command id to convert a user name to a number. Upon running this command, a login window is popped up for the login id specified, see the figure below.

If I change the login id to another user, the login window changes as well:

The 1% that remains is that what I really hope to capture is the login window where all available login ids are shown.

There is a related command (below) that displays the login window I am after, however, this brings me back to the same problem I started with, that is, no means to get a screenshot.

/System/Library/CoreServices/”Menu Extras”/User.menu/Contents/Resources/CGSession -suspend

With some further digging I was able to successfully get the screenshot that I’m after with a couple of approaches:

  1. Using a screen recording program such as ScreenFlow: enable fast user switching, start the recording and select the login window option from the fast user switching dialog. This will capture the sequence of events including the elusive login window.
  2. I also found a few screenshot applications that can successfully capture the login window while running in the background. For example, Christian at MonkeyBread Software wrote a freeware application in REALbasic TimedScreenshot (here’s the source code) that will capture the screenshot I am after:

So, it’s obvious we can get there from here. The question that remains is, what system level API/library can we call to make this happen?

Ideally I’d like to have a very simple application, written in as few lines of code as possible, using tools that are freely available (e.g. Xcode or even better, just terminal commands). If this involves running a program in the background using a terminal command such as sleep (as I did with screencapture in the previous post), that works for me.

Any developers (Cocoa or otherwise) who can take this challenge the last mile?

Technorati Tags: ,

3 responses so far

May 12 2008

Login Screenshot Challenge - Part 1

Published by john under System

In my last post I was showing various options for working with the root account. Near the end of the post I was planning to show how when logging in as root, the login dialog does not offer root as one of the available login names.

Attempting to capture the login screen has been an interesting diversion. Up to this point I’ve been unsuccessful in capturing the elusive screenshot.

So here’s a challenge for you…can you be the first to figure out how to capture a screenshot of the login screen for the root account? There are a couple of ground rules:

  1. You must be running Leopard (or at a minimum, the solution must work on Leopard).
  2. I’d like this to be a “free” solution, as in, no software to buy.
  3. Finally, I am looking for a solution that doesn’t require more than one Mac (e.g. using SSH from one Mac to another).

To save you some time, I’ve listed below the options I’ve tried:

Attempt #1 - Hotkeys
From the login screenscreen, I tried the following hotkeys:

- Shift+Command+3 (capture entire screen to file)
- Control+Shift+Command+3 (capture entire screen to clipboard)
- Shift+Command+4 (capture area defined with mouse to file)
Each of the above greeted me with a pleasant beep, nothing more.

Attempt #2 - Grab application
My next attempt was to try the timed capture option with the Grab application. Seemed like a clever idea, however, when I started the timer and logged out (to get to the login screen), Grab just seems to quietly go away. No warning, no error, no screenshot.

Attempt #3 - Fast Switching
Next, I enabled fast user switching. My thinking was, maybe if I don’t logout per se, and request the Login Window (see the figure below) that the login screen might somehow be different (as in, something I can capture using hotkeys):

Seemed logical, however, first notice that the root account doesn’t show up in the list of available accounts. Next, upon choosing Login Window I was shuffled over to the same login screen as if logging out. No luck.

Attempt #4 - Getting a little more creative, I tried this from within a terminal:

screen -d -m bash -c “sleep 30; screencapture /Users/John/login.png”

This option uses a screen manager (more on that in an upcoming post) and calls the screencapture application after sleeping for 30 seconds. Once I ran this option from a terminal, I quickly logged out and patiently waited…I heard the camera sound of the screencapture application and was psyched, “yes!”…I navigated to my home directory and located the file login.png…I opened the file with the Preview application…and much to my dismay…it was an image alright…a big, black, blank image. So close, but no cigar.

So, now it’s up to you. Can you figure what it takes to capture the login screenshot? You can submit your idea as a comment (below) or drop me an email. And please verify your trick works with Leopard, as other published solutions I’ve found seem to work only on releases prior to Leopard.

I’m doing my best to see if I can find a volunteer to donate a prize (software, book, t-shirt, etc). If that doesn’t come through, what I can offer is a little lime-light, blog style. If you are the first to contact me with a solution (within the parameters above), we can collaborate on a post where you can tell the world how you got so smart :) and share your bio, picture, blog/website, etc.

If anyone reading is interested in donating a prize, contact me and we’ll get the ball rolling.

I am very intrigued to see if/how this can be done.

Technorati Tags: ,

8 responses so far