Go Back   Mac Help Forums > Developer > Shell Programming

Reply
 
Thread Tools Display Modes

Automatic timed screen grab in OS X Tiger !
Old 28th June 2006   #1
Ric
Admin
 
Ric's Avatar
 
Ric is offline
Mac Specs: MacBook Pro 2.5GHz Intel Core 2 Duo, Mac OS 10.5.5
Join Date: May 2004
Location: UK
Posts: 4,313
Blog Entries: 6
Ric is on a distinguished road
Automatic timed screen grab in OS X Tiger !

If you need to capture the Screen on your Mac here is one way of doing it...


First, create a folder on your Desktop called captures.

Next we are going to write a shell script...


Open TextEdit and type:


Code:
#!/bin/sh


screencapture -x /Users/computer/Desktop/captures/`date +%b%d%H:%M:%S`.png
Changing the word 'computer' to your username !



Whats all that code then !!!

Well the first bit tells the Mac what Shell to run the code in. In Tiger the default is 'bash'

The next line...

Code:
screencapture -x
Capture the whole screen without making the camera click sound !

Leave off the -x if you want to hear the camera !

Next bit...

Code:
/Users/computer/Desktop/captures/
This is the 'path' where the screencaptures will be saved, on this Mac my username is 'computer' so the screengrabs will be saved in a folder called 'captures' on my desktop.

You will have to amend this to your own folder, maybe

Code:
/Users/yourUserName/Desktop/
All the files would then go on your Desktop. (remember there will be 20 every hour, so it'll get cluttered !)

The next bit...

Code:
`date +%b%d%H:%M:%S`
This is the unix command 'date' this gets the current date...

June2816/30/23

ie June the 28th 16.30 and 23 seconds.

The next bit...

Code:
.png
The default for Screencapture's via the Terminal is to output a .png file

If you don't have this tagged onto the end of the filename, the files aren't double clickable.


So we now have our Shell Script, do a save as

Code:
screenie.sh
Don't allow TextEdit to add .txt to the end of the name !

Now we need to open Terminal (Applications-->Utilities)

Once Terminal is open then type

Code:
chmod +x
type a space after the x

Don't press return yet...


Find the screenie.sh file and drag it into the terminal so that you get a line similar to this...


Code:
chmod +x /Users/computer/Desktop/screenie.sh

Now you can press the return key !

This line turns screenie.sh into an executable file, ie it's now like a little application that the shell can 'run'.

Now move the screenie.sh file somewhere safe, maybe in the Applications folder if you want.

Now download Launchd editor from here.

This is not technically needed but it makes life easier ! Please pay the Developer if you use the App a lot !

Now have a look in this folder,

Code:
Users/yourusername/Library
Is there a folder called 'LaunchAgents' if there isn't then create one.

Now open up Launchd editor.

We are now going to create the 'Screenie plist file'

Just edit as the screen grabs below...






Changing your path info as neccesary !


On my Mac I have left the screenie.sh file on the Desktop !

In the second pic above the 300 seconds will mean that the Shell Script will run every 5 minutes ! Change to suit your needs !



Now save that file as screenie.plist in the 'LaunchAgents' folder that you created above.

Now back to Terminal and type...

Code:
launchctl load /Users/computer/Library/LaunchAgents/screenie.plist
Again changing the path as necessary !

Now, best to reboot ! You are done !

Every 5 minutes a new screen grab is taken and saved to where you specified...

You can always extend this to then email the Screen Grab...FTP it somewhere what ever you want !

To turn it of...

Code:
launchctl unload /Users/computer/Library/LaunchAgents/screenie.plist
Again replace the path as neccesary !



You should end up with something like this...





regards

Ric
__________________
Please post your questions in the forums this is the quickest way of getting help.



  Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Interesting thoughts on filming the screen tartansparkle Mac OS X System Software 4 1st February 2007 10:11 PM
A few Tiger jokes Ric Jokes & Humor 0 17th May 2005 10:55 PM


| Copyright ©2002-2008 mac-help.com. All Rights Reserved. | Archive | Mod | Admin | Contact Us |