Starscape

Example Apple Scripts

Here a few useful Apple Scripts that we use with iAway.

Below a collection of example Apple Scripts which can be used for iAway, that can do all kinds of useful actions when you step away from your Mac and return.

Mac Sleep

This small Apple Script asks your Mac to sleep when away. It is great to use this as the last step when used in combination with other apple script actions.

1
2
3
-- Ask Mac to sleep
tell application "Finder" to sleep
-- That's it :-)

Start Screen Saver

This small Apple Script starts your Screen Saver. It is great to use this as the last step when used in combination with other apple script actions when you are away.

1
2
3
4
5
6
7
--Start Screen Saver
try
	tell application "ScreenSaverEngine"
		activate
	end tell
end try
--All Done :-)

Set Skype status and activate Screen Saver

This handy example Apple Script sets your Skype status to “Away” and activates your Screen Saver when you are away from your Mac. When you return, it sets your Skype status back to “Online”.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- Set Skype Status to Away
try
	tell application "Skype"
		send command "GET USERSTATUS" script name "iAway"
		set outcome to the result
		if outcome is "USERSTATUS ONLINE" then
			send command "SET USERSTATUS AWAY" script name "iAway"
		end if
	end tell
on error errString number errorNumber
	log (errString)
end try
--Start Screen Saver
try
	tell application "ScreenSaverEngine"
		activate
	end tell
end try
--All Done :-)
1
2
3
4
5
6
7
8
9
10
11
12
13
-- Set Skype Status to back to Online
try
	tell application "Skype"
		send command "GET USERSTATUS" script name "iAway"
		set outcome to the result
		if outcome is "USERSTATUS AWAY" then
			send command "SET USERSTATUS ONLINE" script name "iAway"
		end if
	end tell
on error errString number errorNumber
	log (errString)
end try
--All Done :-)

Set Adium status

This example Apple Script sets your Adium status to “Away” and when you are away from your Mac. When you return, it sets your status back to “Online”.
1
2
3
4
5
6
7
8
9
-- Set Adium status to Away
try
	tell application "Adium"
		go away (every account)
	end tell
on error errString number errorNumber
	log (errString)
end try
-- All Done :-)
1
2
3
4
5
6
7
-- Set Adium status back Online
try
	tell application "Adium" to go available
on error errString number errorNumber
	log (errString)
end try
-- All Done :-)

Do you have any other useful Apple Scripts that you run when away from your Mac?
If so, let us know and we will add them to this list!

Pin It on Pinterest

Share This