Sunday, April 8, 2007

Screenshots in xGestures

Just earlier today someone emailed me asking if there was some way to create gestures in xGestures that would take screen shots, like pressing command-shift-3.  I figured it would be a pretty simple thing, since you can create keystroke actions and just have one of those press command-shift-3.  What I found out is that even if you get passed the first hurdle of figuring out how to enter that keystroke the xGestures preference pane without actually taking a screenshot instead, it still doesn't work.  There's a bug in xGestures I'm going to try to address as soon as I get the chance to make those sorts of keystrokes work, because apparently any kind of system-level key command can't be triggered by xGestures.

Not to be defeated, though, I figured that maybe there was some kind of neat way to do it using AppleScript.  And sure enough, there is.  Hidden in Mac OS X is the unix command screencapture, which can be used to take screenshots in exactly the same way as pressing Command-Shift-3.  Unfortunately it requires you to give it a path to a file, rather than defaulting to saving the screenshot to the desktop in the form of 'Picture N', so I had to code something in there to make it do that on its own.  But here are three AppleScripts you can use with xGestures (or anything that can run AppleScripts, like Quicksilver) for taking screenshots:

This will take a screenshot normally, just like pressing Command-Shift-3:

repeat with i from 1 to 999
    set pathToTest to ("~/Desktop/Picture\\ " & i & ".png")
        do shell script ("/bin/ls " & pathToTest)
    on error
        exit repeat
    end try
end repeat
do shell script "screencapture " & pathToTest

To make it behave like pressing command-shift-4, replace the last line with:
do shell script "screencapture -i " & pathToTest

or to make it behave like pressing command-shift-4-space, replace the last line with:
do shell script "screencapture -iW " & pathToTest

Hopefully someone might find these useful.  There's some other AppleScripts I wrote in response to user questions for xGestures, and at some point in the future I'll probably post them, since other people might like to have them too.


F451 said...

Will xGestures be Leopard compatible? I cannot live without it, and I am willing to pay an upgrade fee just to have it working in Leopard.

And how do I go about changing my registration email address as I now use a Gmail account? I have the original email from my purchase with my registration information.


Cctoide said...

Hey man! Great to see you have a blog... was wondering if one day I might get to know the man behind The Demented Cartoon Movie (sorry if that brought back bad memories :P).

And I thought you'd fallen off the internet for good...

ralph nader said...


Anonymous said...

I would like to have a xGestures version for Leopard because it doesn´t works fine in 10.5.1

Anonymous said...

Very valuable idea

Anonymous said...

Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!

Anonymous said...

Good day! Would you mind if I share your blog with my zynga group?
There's a lot of people that I think would really enjoy your content. Please let me know. Thank you

Visit my web blog; Restaurant Near Disney World

Anonymous said...

each time i used to read smaller articles that as well clear their motive, and that is also happening with this piece of writing which I am
reading at this place.

Feel free to visit my webpage:

Anonymous said...

I almost never leave a response, however after reading
a few of the comments on this page "Screenshots in xGestures".
I actually do have a few questions for you if you do not mind.
Could it be just me or do a few of these responses appear
like they are written by brain dead people? :-P And, if you are posting on other sites, I'd like to keep up with anything new you have to post. Would you post a list of all of all your social pages like your linkedin profile, Facebook page or twitter feed?

my web blog - golf galaxy coupon code 2012

Anonymous said...

Good day! I know this is kind of off topic but I was wondering
which blog platform are you using for this site?
I'm getting sick and tired of Wordpress because I've had
issues with hackers and I'm looking at options for another platform. I would be fantastic if you could point me in the direction of a good platform.

Also visit my web blog golf channel the golf fix

Anonymous said...

What's up friends, its great post concerning cultureand entirely explained, keep it up all the time.

Feel free to visit my blog post :: golf buggy batteries in manchester area

Anonymous said...

This article will help the internet viewers for creating new webpage or
even a blog from start to end.

Feel free to surf to my site ... sunbrella golf cart seat covers

Anonymous said...

Simply wish to say your article is as astounding.
The clarity on your post is just nice and i can suppose you're knowledgeable on this subject. Well with your permission let me to take hold of your feed to keep updated with drawing close post. Thank you 1,000,000 and please carry on the enjoyable work.

my web site left handed golf club sets cheap

Anonymous said...

I wanted to thank you for this wonderful read!! I certainly loved every bit of it.

I have you saved as a favorite to look at
new things you post…

Feel free to visit my page ... golf accessories gifts + india