Fun Scripting!

Hi!

Let me just say first, I LOVE THIS PLACE!
I was just tinkering on my startup script, I have it open my apps, set a few settings, and edit the volume. I was wondering if anyone has any cool or helpful little tips or scriplets I could add?

This is what I do on wakeup (I never shut down - just sleep):


tell application "FastScripts" to set Note_1 to display message "Powering Up" at screen position center dismissing after delay 0

activate application "Jiggler" -- prevents sleep without changing settings.

-- Turn on work Lamps - I have a Powerkey Pro 650; a USB-controlled 6-outlet power bar.
tell application "PowerKey Daemon"
	try
		set level of outlet 3 of unit "PKP" to 100
	on error
		delay 2
		set level of outlet 3 of unit "PKP" to 100
	end try
end tell

tell application "FastScripts" to set autodismiss time of Note_1 to 0.01 -- dump the note

open location "http://bbs.applescript.net/" -- tune in the MacScripter bbs

-- A script that extracts upcoming events from iCal and displays them in a Growl notification
run script alias ((path to scripts folder from user domain as text) & "Application Scripts:iCal:MiCal.scpt")
delay 1

-- A script that extracts the next four birthdays from an iCal calendar called Birthdays and displays them in a Growl notification
run script alias ((path to scripts folder from user domain as text) & "Application Scripts:iCal:Birthdays:Birthdays.scpt")
delay 1

-- A script that checks to see if my IP Address has changed and notifies me if it has
run script alias ((path to scripts folder from user domain as text) & "Internet:GetIP.scpt"
delay 1

-- A script that checks my email (Eudora) and opens mailboxes with unread mail
run script alias ((path to scripts folder from user domain as text) & "Application Scripts:Eudora:EudoraCheck.scpt"
tell application "Eudora" to activate

ADDER: If you’re willing to do a little Terminal work, SleepWatcher will run a script when you wake up your Mac or when it goes to sleep.

Is there any way to get a script to run on wake without the terminal work, I am just starting to get a handle on applescript and I doubt I’m ready for terminal.

I don’t think so - I’ve never seen one. If I ever get around to writing an AppleScript installer for SleepWatcher, I’ll post it in Code Exchange.

Actually, I used SW for a while and then stopped because when I awoke the machine for something brief like a phone number, I didn’t want to wait for the rest. Now, my method is tap the spacebar to wake the machine, then tap my hotkey for the wakeup script if I’m sitting down to work. I use FastScripts to assign hot keys

I took a look at FastScript, but for shortcuts I prefer to use Quicksilver, a great little bit of freeware. Anyway, thanks for the tip!

I use Quicksilver as well. FastScripts replaces your scripts menu and allows assigning key codes to scripts. The scripts do not need to be applications (none of mine are) but they run either from the menubar menu or with the keycode. I realize that exactly the same behavior is possible with QuickSilver, but I prefer not to clutter it up with 1800 scripts.

I’m still a noob, but really interested in scripting. What sort of functions do your scripts do, I’m looking for fun ideas for things to build.

With reference to my startup above:

Jiggler is a tiny app that moves the cursor of your machine in a tiny circle ever ‘n’ minutes so the machine will never sleep while it’s running. When you quit it, all your sleep settings apply normally.

My ‘MiCal’ script goes to one of my calendars and posts a Growl notification of the upcoming events on it. (It doesn’t have many - I use a lot of categories of calendars to make finding specific things easy).

My ‘Birthdays’ script extracts the next four birthdays (for an extended family) that are coming up on my Birthdays calendar and posts a Growl notification of how many days remain until each birthday for each person.

The IP Address script ‘GetIP’ has a stored preference (.plist) file of the last IP address external to my router. It compares that value to the value at wakeup and informs me in a notification if it has changed, then updates the .plist. I check to see that dyndns.org has updated properly.

Finally, ‘EudoraCheck’ checks all of my mailboxes for unread mail (that is not in the trash) and opens every mailbox that has unread mail in it.

Hi Jamie,

AppleScript Studio is a lot more fun then, regular AppleScript. Regular AppleScript is mainly for making tasks easier although making scripts for iTunes might be fun. Speech recognition is kind of fun also, but you need a good microphone. Doing Internet stuff might be fun. Like uploading to your home page or getting info. Maybe soap/rpc might be fun. The most fun is sitting back and resting or doing things you need to do, while your computer does everything on its own. :slight_smile:

gl,

Cool!

I should have been clearer, I meant what are your best or favourite scripts out of all you’ve ever made.

Oh, and about Studio, I’m very happy, I just finished my first app, and it is bugless!!!

On my machine,


set FC to count (list files of (path to scripts folder from user domain)) --> 1861 now

so I sure can’t recall which of them I thought to be most favored. I’ve posted a bunch of them to Code Exchange - so I guess those were, in some sense, favorites.

WOW!!!
Anyway, nice talking to you!

What is the script you use for determining your IP? Searches here are tough because “ip” gets knocked off, being under 4 letters.


-- Using http://checkip.dyndns.org/ and FastScripts Notification
-- keeps a record in IPHistory, variable called OIP
set myIP to word 25 of (do shell script "curl checkip.dyndns.org")
set chg to true
set dyndns to true
try
	set oldIP to (do shell script "defaults read IPHistory 'OIP'")
on error
	do shell script "defaults write IPHistory 'OIP' " & myIP
	set oldIP to myIP
end try
if myIP = oldIP then
	set chg to false
else
	-- check dyndns.org's version
	set theURL to "http://myDomain.ca"
	try
		set ORG to (dotted decimal form of ((theURL as URL))'s host)
	on error
		set dyndns to false
	end try
	set myTitle to "IP Address Changed!" & return & return
	set msg to "Now " & myIP
	do shell script "defaults write IPHistory 'OIP' " & myIP
	if ORG = myIP and dyndns then
		set msg to msg & return & "dyndns.org updated"
	else
		set msg to msg & return & "dyndns.org NOT set"
	end if
end if
if chg or not dyndns then -- this could just as well be a 'display dialog msg'
	tell application "FastScripts" to display message myTitle & msg at screen position top left dismissing after delay 4
end if

Thanks a lot, that first line is exactly what I needed. In my startup script this runs and show me my IP.

I have different scripts, the one I use when starting up is to mount all the servers I want.
(works with Xcode or apple script studio, with a preference window to add more servers)

Then I have a script for when I using FTP, works with Transmit and Cyberduck, it saves all the FTP adresses, with login and password and with the preferene of Cyberdick or Transmit to use, the adresses I save on a server, so anyone in the company has the same info.

Different scripts that work with graphic applications like InDesign, Photoshop and Quark, to make PDF files, relink images and convert images to the correct size and with the correct color space and profile.

And a few months ago I made a script for database publishing: works with FileMaker, this displays the contents on the web, the customer can correct this, and after that makes in InDesign the complete document, incluse images, text in correct font, logo’s etc. etc.

Scripting is fun and save a lot of time in the production.