Automation: Difference between revisions

From Medien Wiki
Line 26: Line 26:
=== ScreenUtil ===
=== ScreenUtil ===
[http://www.osxsoft.net ScreenUtil] lets you set the screen resolution over the command line.
[http://www.osxsoft.net ScreenUtil] lets you set the screen resolution over the command line.
== AppleScript ==
Unfortunately on can't use the control panel to only switch on the computer at certain days of the week. What you can do is check the day of the week and then shut the computer down again if it isn't the right day.
<source lang="applescript">
-- wenn nicht Mittwoch, Samstag oder Sonntag it, dann schalte den rechner wieder aus.
set closed_Days to {Monday, Tuesday, Thursday, Friday}
if closed_Days contains ((current date)'s weekday) then
tell application "System Events"
shut down
end tell
return
end if
-- Systemlautstärke voll
set volume 5
-- QuickTime starten
tell application "Finder"
activate
open application file "QuickTime Player.app" of folder "Applications" of startup disk
end tell
tell application "QuickTime Player"
activate
open file "Macintosh HD:Users:name:Documents:Folder:subfolder:my_sound.wav"
set looping of document "my_sound.wav" to true
set audio volume of document "my_sound.wav" to 0.5
play document "my_sound.wav"
end tell
</source>
== Automator ==

Revision as of 17:13, 12 May 2011

Wehn setting up installations for exhibitions Automating the startup and shutdown is essential in order to make sure your piece is actually running. Never rely on staff to switch on things.

Programmable time switches

are quite cheap and very useful

Zeitschaltuhr.jpg

Startup and shutdown

OS X has startup and shutdown automation included, it's hidden in the Energy Saving preference pane.

OS X Preference Panes.png

Energie sparen.png

Zeitplan.png

Do something on startup

OS X can launch a script or application on startup. you can set this in the Users preference pane under startup items.

Startobjekte.png

shell scripts

shell scripting is a convenient way how to script stuff. Make sure you make the script executable and use the extension .command

cliclick

cliclick with this utility you can even click on things over the command line

ScreenUtil

ScreenUtil lets you set the screen resolution over the command line.

AppleScript

Unfortunately on can't use the control panel to only switch on the computer at certain days of the week. What you can do is check the day of the week and then shut the computer down again if it isn't the right day.

-- wenn nicht Mittwoch, Samstag oder Sonntag it, dann schalte den rechner wieder aus.

set closed_Days to {Monday, Tuesday, Thursday, Friday}
if closed_Days contains ((current date)'s weekday) then
	 tell application "System Events"
		shut down
	 end tell
	 return
end if

-- Systemlautstärke voll
set volume 5

-- QuickTime starten
tell application "Finder"
	activate
	open application file "QuickTime Player.app" of folder "Applications" of startup disk
end tell
tell application "QuickTime Player"
	activate
	open file "Macintosh HD:Users:name:Documents:Folder:subfolder:my_sound.wav"
	set looping of document "my_sound.wav" to true
	set audio volume of document "my_sound.wav" to 0.5
	play document "my_sound.wav"
end tell

Automator