A rookie's daring project

Greetings MacScripters! Truly a pleasure to be here

I’ll go ahead and start by saying that, as the subject suggests, I am completely new to Applescript. I do, however, have years of experience with OS X itself dating back to Panther, although most of everything I know stems from Tiger. I feel I have a decent understanding of the OS and how to get what I need out of it.

That being said, my colleagues and I are currently in a position where we deal with Macs on a daily basis, and by my colleagues I mean me. I take care of virtually everything Apple related as they prefer not to touch them for fear of the unknown. What I am looking to accomplish here is to provide a very quick and simple way for those other guys to be able to accurately and consistently perform a set of simple set up tasks. Here’s where my Applescript idea comes into play. I would like to create a script or set of scripts that will be launched from a disc to perform the tasks for them (and myself because it’s faster.)

First of all, this is the list of things I would like accomplished by the script so far:

OS X 10.6 running on all Apple desktop and laptop models

** “X” denotes what I figured out, “??” for attempts (and frustrations), and nothing meaning I haven’t looked into it yet**

I’ve spent many hours researching various scripts and guides via Google and so far have come up with this:


--> Sets the Preferences for Finder
tell application "Finder"
	tell Finder preferences
		set desktop shows hard disks to true
		set desktop shows connected servers to true
		set desktop shows external hard disks to true
	end tell
end tell

--> Arranges the desktop icons in a grid
tell application "Finder"
	set arrangement of icon view options of window of desktop to snap to grid
end tell

--> Sets the Appearance settings in System Preferences
tell application "System Events"
	tell appearance preferences
		get properties
		
		set properties to {scroll arrow placement:top and bottom, font smoothing limit:4, recent applications limit:10, scroll bar action:jump to here, double click minimizes:false, recent servers limit:10, appearance:blue, recent documents limit:10, highlight color:blue, smooth scrolling:true, font smoothing style:light}
	end tell
end tell

--> Sets the Dock in System Preferences
tell application "System Events"
	tell dock preferences
		get properties
		
		set properties to {minimize effect:scale, location:bottom, autohide:false, magnification:true, magnification size:0.8, dock size:0.5}
	end tell
end tell

-- GET AND SET PROPERTIES
tell application "System Events"
	tell expose preferences
		tell spaces preferences
			set spaces enabled to true
			
			get properties
			
			-- SET THE PROPERTIES AND APPLICATION ASSIGNMENTS
			set properties to {spaces rows:2, spaces columns:2}
			set application bindings to {}
			
			-- SET MODIFIERS OF SWITCHING KEYS
			properties of arrow key modifiers
			-- {class:spaces shortcut, key modifiers:{control}}
			set key modifiers of arrow key modifiers to {control}
			properties of numbers key modifiers
			-- {class:spaces shortcut, key modifiers:{control}}
			set key modifiers of numbers key modifiers to {control}
		end tell
	end tell
end tell

Granted, there was fair amount of copy an paste involved, but I did manage to learn a few core concepts around what I’m trying to do here and I applied those where what was written didn’t exactly match what I was looking for.

My questions to you are, 1) Is this something that can be done with Applescript (and/or Automator), and 2) Would you be willing to help me along with my project if it is?

I’m not asking anyone to write it for me. I’d really like to be able to learn from this. Scripting is something I’ve never really delved into before, and this seems like a great opportunity to get started. Creating this script isn’t a necessity, it’s more of a personal quest. Lion will be out in a month and likely render this useless anyway, but I’d still like to try.

Any advice, links, tutorials, ideas, etc will be greatly appreciated!

I might be able to help with

There’s nothing in Keychain Access Scripting as you may have found.
It is doable, however, by writing directly to the plist which controls (part of) the display of menu extras.
This is com.apple.systemuiserver. It has a key “menuExtras” which lists the nonstandard extras that should be displayed.
When the Keychain extra is showing there’s an entry with value “/Applications/Utilities/Keychain Access.app/Contents/Resources/Keychain.menu”.
You could add this by hand for a single user (silly), but the script linked above will show you how automate this, and many other things in your ‘wishlist’ ;).