Monday, August 16, 2010

DIYWake 2.3

Introduction:
Would it not be great if you could use your Mac as an alarm clock with iTunes? I could not find an app that does wake up my Mac and start iTunes at a given time AND is FREE.
I found one of Doug's AppleScripts for iTunes very useful. It opens iTunes and slowly raises the volume from 0 till it reaches it's last position, so I implemented it here.

What this Script does:
The script creates everything needed to wake up your Mac and start playing iTunes while slowly raising the volume:
- Create new calendar "DIYWake" in iCal
- Create new event that launches a script at a certain time
- Set the schedule in Energy Saver to wake the Mac one minute before the iCal event
- Create AppleScript that launches iTunes, raises volume and reset Energy Saver

What you need:
AppleScriptEditor

Preparations:
- See Mini-How-To's on how to create a script, or app
- Set iTunes to the music you want to hear
- Set the volume in iTunes as high as you want it to be when done

Running the script:
- just double click it.


-- DIYWake 2.3 (updated 18.08.2010)

-- creates some paths and files needed for the script to work properly


tell application "Finder"

try

make new folder at (path to home folder as string) & "Library:Application Support:" with properties {name:"DIYStudio"}

make new folder at (path to home folder as string) & "Library:Application Support:DIYStudio:" with properties {name:"DIYWake"}

make new folder at (path to home folder as string) & "Library:Application Support:DIYStudio:DIYWake:" with properties {name:"HelperFiles"}

on error

try

make new folder at (path to home folder as string) & "Library:Application Support:DIYStudio:" with properties {name:"DIYWake"}

make new folder at (path to home folder as string) & "Library:Application Support:DIYStudio:DIYWake:" with properties {name:"HelperFiles"}

on error

try

make new folder at (path to home folder as string) & "Library:Application Support:DIYStudio:DIYWake:" with properties {name:"HelperFiles"}

end try

end try

end try

end tell


-- creates one of Doug's AppleScripts for iTunes. You can change how fast iTunes reaches the max Volume by changing the ticks per time (thismany = seconds)


on my_handler(my_pass, time_returned)

set playiTunesHelper to (path to home folder as string) & "Library:Application Support:DIYStudio:DIYWake:playiT.scpt" as string

set playiTunesHelperReference to open for access playiTunesHelper with write permission

set file_path to (POSIX path of (playiTunesHelper))

set shellPath to (POSIX path of (path to home folder as string)) & "Library/Application\\\\ Support/DIYStudio/DIYWake/playiT.scpt"

set eof of playiTunesHelperReference to 0

set playiTunes to "property tick : 5

property thismany : 3

tell application \"iTunes\"

run

set snd to sound volume

set sound volume to 0

play

repeat

if (get sound volume) is greater than or equal to (snd - tick) then

set sound volume to snd

exit repeat

end if

set sound volume to (sound volume + tick)

delay thismany

end repeat

end tell

try

tell application \"iCal\"

tell calendar \"DIYWake\"

set event_summary to \"DIYWake\"

set all_events to every event

repeat with this_event in all_events

tell this_event

delete

end tell

end repeat

end tell

end tell

end try

do shell script \"sudo pmset repeat cancel\" password \"" & my_pass & "\" with administrator privileges

do shell script \"sudo rm " & shellPath & "\" password \"" & my_pass & "\" with administrator privileges

do shell script \"sudo -k\""

write playiTunes to playiTunesHelperReference starting at eof

close access playiTunesHelperReference

-- some time calculations to convert the input to the right format and set wakup time 30 second earlier than the iTunes script starts

set itemized to every character of time_returned as list

if ":" is not in itemized then

if length of time_returned = 3 then

set time_returned to "0" & (item 1 of itemized) & ":" & (item 2 of itemized) & (item 3 of itemized)

end if

if length of time_returned = 4 then

set time_returned to (item 1 of itemized) & (item 2 of itemized) & ":" & (item 3 of itemized) & (item 4 of itemized)

end if

end if

if ":" is in itemized then

if length of time_returned = 4 then

set time_returned to "0" & time_returned

end if

end if

set tempSeconds to ":00"

set time_complete to (date string of (current date)) & " " & time_returned & tempSeconds

set time_complete to date (time_complete)

set time_2 to time string of (time_complete)

set time_1 to time string of (current date)

if time_2 < time_1 then

set anfangsdatum to (current date) + 1 * days

set anfangsdatum to (date string of (anfangsdatum)) & " " & (time string of (time_complete))

set anfangsdatum to date (anfangsdatum)

else

set anfangsdatum to time_complete

-- set anfangsdatum to (anfangsdatum) + 1 * minutes

end if

set timeToWake to (time string of (time_complete - 30))

-- creates calendar and event named "DIYWake" which launches the script for iTunes

tell application "iCal"

set cal_list to {}

repeat with x from number of calendars to 1 by -1

set the beginning of cal_list to name of calendar x

end repeat

set cal_list_string to ""

repeat with x from 1 to number of calendars

set cal_list_string to cal_list_string & (x as text) & " - " & item x of cal_list & return

end repeat

if "DIYWake" is not in cal_list then

create calendar with name "DIYWake"

end if

tell calendar "DIYWake"

set x_date to anfangsdatum

set event_summary to "DIYWake"

set all_events to every event

repeat with this_event in all_events

tell this_event

delete

end tell

end repeat

make new event at the beginning with properties {summary:event_summary, start date:x_date, end date:x_date}

set theEvent to first event

tell theEvent

make new open file alarm at end with properties {trigger date:x_date, filepath:file_path}

end tell

end tell

end tell

delay 1

do shell script "sudo pmset repeat wakeorpoweron MTWRFSU " & timeToWake password my_pass with administrator privileges

delay 1

do shell script "sudo -k"

end my_handler


-- displays the dialogs

display dialog "Tell me what you want...bitch!" buttons {"New Alarm", "Delete existing Alarm", "Cancel"} default button 1

set the button_pressed to the button returned of the result


if the button_pressed is "New Alarm" then

display dialog "When may I wake you?" default answer "07:30" buttons {"Set Alarm only", "Sleep now", "Cancel"} default button 1

copy the result as list to {time_returned, button_pressed}

if button_pressed is "Set Alarm only" then

display dialog "Enter password" default answer "" buttons {"OK", "Cancel"} default button 1 with hidden answer

copy the result as list to {my_pass, button_pressed}

my_handler(my_pass, time_returned)

else if button_pressed is "Sleep now" then

display dialog "Enter password" default answer "" buttons {"OK", "Cancel"} default button 1 with hidden answer

copy the result as list to {my_pass, button_pressed}

my_handler(my_pass, time_returned)

tell application "Finder" to sleep

end if

-- deletes existing alarm in calendar and resets Energy Saver

else if the button_pressed is "Delete existing Alarm" then

try

display dialog "Enter password" default answer "" buttons {"OK", "Cancel"} default button 1 with hidden answer

copy the result as list to {my_pass, button_pressed}

do shell script "sudo pmset repeat cancel" password my_pass with administrator privileges

do shell script "sudo rm /Users/docno/Library/Application\\ Support/DIYStudio/DIYWake/playiT.scpt" password my_pass with administrator privileges

do shell script "sudo -k"

end try

try

tell application "iCal"

tell calendar "DIYWake"

set event_summary to "DIYWake"

set all_events to every event

repeat with this_event in all_events

tell this_event

delete

end tell

end repeat

end tell

end tell

end try

end if



Monday, May 24, 2010

Updated Baking Script to Version 0.95

It is now possible to trigger the script without Keyboard Maestro, or any other additional software.

See the Mini-How-To's to create a service, or add the script to the script menu.

Go to the Original Post for instructions and download

Wednesday, May 5, 2010

Werbespot Kickershirts.com, Pörx, Astra

Ein Werbespot für die beste kleine Kneipe Berlins. Das Projekt startete im Sommer 2009. Die ursprüngliche Idee kam vom legendären Kicker-Belgier Thomas und wurde von Fred und mir so lange weiter gesponnen, bis wir sie unbedingt umsetzen wollten. Das dabei das Finanzielle ganz weit hinten anstehen musste, war uns klar, aber als eingefleischte Pörx-Gänger und Kicker-Spieler wären wir sogar bereit gewesen drauf zu zahlen. Schließlich würde es ein Gemeinschaftsprojekt einiger eingefleischter Pörxer werden und somit mehr Spaß als Arbeit.
Und so war es dann eigentlich auch. Innerhalb kurzer Zeit stellte ich mit Stefan zusammen das Skript fertig und Thomas kümmerte sich fleißig um die Zustimmung vom Pörx-Chef Jürgen und sonstigem organisatorischem Kram. Nach Statisten mussten wir nicht lange suchen, jeder unserer Auserwählten stimmte sofort zu.
Dank Fred kamen wir kostenlos an gutes Licht-Equipment und für die Leihgebühr der Steadycam kam Jürgen auf.
Für den Dreh hatten wir relativ wenig Zeit, aber nach kurzen Anlaufschwierigkeiten verlief er dank der fleißigen Statisten ziemlich glatt.
Updates zum Schnitt usw. gibt''s bei Twitter


Edit: Fertig! Astra hat uns die Markenfreigabe erteilt und man darf den Spot jetzt bewundern :)

Saturday, April 10, 2010

Automated Export/Import in FCP (Baking) Version 0.95

Introduction:

With Color 1.5 the compatibility with transitions and speedchanges got better, but sometimes you still have to render some clips before you can send a timeline from Final Cut to Color without getting any errors. And if you are still working with Color 1.0 (like I do) you need this anyway.
There will be newer versions of this script. If you need it a bit different, drop me a line and I'll add or remove functions.

What this Script does:
Exports clips from FCPs timeline and imports them to same location (called "baking" clips).

What you need:
OS X, Final Cut Pro, AppleScript Editor,
Keyboard Maestro to assign a Keyboard Shortcut to trigger the script. Unfortunately the script does not work through the script menu or as a service :(

Preparations:

See Mini How To's to
  • Create Applescript with following code and save to the standard script folder.

Baking Script 0.95 (24.05.2010)

- Now possible to trigger the script without Keyboard Maestro, or any other additional software.


activate

set PropertyList to {"Bake video only", "Bake with audio"} -- create a list for different settings


set the ChosenItem to choose from list PropertyList default items {item 1 of PropertyList}

set ChosenItem to ChosenItem as string


if ChosenItem is "Bake video only" then

-- textfiles that store name and path information

set ClipnameHelper to (path to home folder as string) & "Library:Application Support:DIYStudio:HelperFiles:Clipname.txt" as string

set CounterHelper to (path to home folder as string) & "Library:Application Support:DIYStudio:HelperFiles:Counter.txt" as string

set pathhelper to (path to home folder as string) & "Library:Application Support:DIYStudio:HelperFiles:Complete.txt" as string

set PathToClipFolder to (POSIX path of (choose folder))

try

set pathhelperReference to open for access pathhelper with write permission

on error

tell application "Finder" -- if you run the script for the first time it will create the text files that help storing last used names and counter

make new folder at (path to home folder as string) & "Library:Application Support:" with properties {name:"DIYStudio"}

make new folder at (path to home folder as string) & "Library:Application Support:DIYStudio:" with properties {name:"HelperFiles"}

set pathhelperReference to open for access pathhelper with write permission

end tell

end try

set eof of pathhelperReference to 0

write (PathToClipFolder as string) to pathhelperReference starting at eof

set shortPathToClipFolder to read pathhelperReference from 1

close access pathhelperReference

set ClipnameHelperReference to open for access ClipnameHelper with write permission

try

set ClipnameHelperContents to read ClipnameHelperReference as string from 1

on error

write "Baked" to ClipnameHelperReference starting at eof

set ClipnameHelperContents to read ClipnameHelperReference as string from 1

end try

set eof of ClipnameHelperReference to 0

set Clipname to text returned of (display dialog "Enter clipname:" default answer ClipnameHelperContents)

write Clipname to ClipnameHelperReference starting at eof

close access ClipnameHelperReference

set CounterHelperReference to open for access CounterHelper with write permission

try

set CounterHelperContents to read CounterHelperReference

on error

write "0" to CounterHelperReference starting at eof

set CounterHelperContents to read CounterHelperReference as string from 1

end try

set counter to CounterHelperContents + 1

set eof of CounterHelperReference to 0

write counter as string to CounterHelperReference starting at eof

close access CounterHelperReference

set combinedClipname to Clipname & " " & (counter as string)

tell application "Final Cut Pro" to activate

-- this section runs the actual activity. You can copy everything and then adjust the following to get different settings. E.g. if you want to render audio and video, you could delete the tab and arrow keys. Or if you want to use a different codec, remove only one tab and add down arrow to choose the setting

tell application "System Events" to keystroke "i" using command down & shift down

delay 0.5

tell application "System Events" to keystroke "e" using command down

delay 0.5

tell application "System Events" to keystroke "g" using command down & shift down

delay 0.5

tell application "Finder" to set the clipboard to shortPathToClipFolder as string

delay 0.5

tell application "System Events" to keystroke "v" using command down

delay 0.5

tell application "System Events" to keystroke return

delay 0.5

tell application "Finder" to set the clipboard to combinedClipname

delay 1

tell application "System Events" to keystroke "v" using command down

delay 1

tell application "System Events" to keystroke tab

tell application "System Events" to keystroke tab

tell application "System Events" to keystroke tab

tell application "System Events" to keystroke tab

tell application "System Events" to keystroke tab

tell application "System Events" to keystroke tab

tell application "System Events" to keystroke tab

tell application "System Events" to keystroke tab

tell application "System Events" to key code 125 -- down arrow

tell application "System Events" to key code 125

tell application "System Events" to key code 125

tell application "System Events" to keystroke return

tell application "System Events" to keystroke return

set myFile to (PathToClipFolder & combinedClipname & ".mov")

delay 1

-- compares the filesize of the new clip over time. As long s it increases it means that it's still rendering

set Size_1 to size of (info for myFile) -- get initial size

delay 2

set Size_2 to size of (info for myFile)

repeat while Size_2Size_1 --if they don't equal, loop until they do

set Size_1 to size of (info for myFile) -- get initial size

delay 1

set Size_2 to size of (info for myFile)

end repeat

-- importing...

tell application "System Events" to keystroke "i" using command down

delay 1

tell application "System Events" to keystroke "g" using command down & shift down

tell application "Finder" to set the clipboard to myFile as string

delay 0.5

tell application "System Events" to keystroke "v" using command down

tell application "System Events" to keystroke return

tell application "System Events" to keystroke return

delay 0.5

tell application "System Events" to key code 21 using command down

delay 0.5

tell application "System Events" to keystroke return

delay 0.5

tell application "System Events" to key code 109 -- F10 key

else if ChosenItem is "Bake with audio" then

-- textfiles that store name and path information

set ClipnameHelper to (path to home folder as string) & "Library:Application Support:DIYStudio:HelperFiles:Clipname.txt" as string

set CounterHelper to (path to home folder as string) & "Library:Application Support:DIYStudio:HelperFiles:Counter.txt" as string

set pathhelper to (path to home folder as string) & "Library:Application Support:DIYStudio:HelperFiles:Complete.txt" as string

set PathToClipFolder to (POSIX path of (choose folder))

try

set pathhelperReference to open for access pathhelper with write permission

on error

tell application "Finder" -- if you run the script for the first time it will create the text files that help storing last used names and counter

make new folder at (path to home folder as string) & "Library:Application Support:" with properties {name:"DIYStudio"}

make new folder at (path to home folder as string) & "Library:Application Support:DIYStudio:" with properties {name:"HelperFiles"}

set pathhelperReference to open for access pathhelper with write permission

end tell

end try

set eof of pathhelperReference to 0

write (PathToClipFolder as string) to pathhelperReference starting at eof

set shortPathToClipFolder to read pathhelperReference from 1

close access pathhelperReference

set ClipnameHelperReference to open for access ClipnameHelper with write permission

try

set ClipnameHelperContents to read ClipnameHelperReference as string from 1

on error

write "Baked" to ClipnameHelperReference starting at eof

set ClipnameHelperContents to read ClipnameHelperReference as string from 1

end try

set eof of ClipnameHelperReference to 0

set Clipname to text returned of (display dialog "Enter clipname:" default answer ClipnameHelperContents)

write Clipname to ClipnameHelperReference starting at eof

close access ClipnameHelperReference

set CounterHelperReference to open for access CounterHelper with write permission

try

set CounterHelperContents to read CounterHelperReference

on error

write "0" to CounterHelperReference starting at eof

set CounterHelperContents to read CounterHelperReference as string from 1

end try

set counter to CounterHelperContents + 1

set eof of CounterHelperReference to 0

write counter as string to CounterHelperReference starting at eof

close access CounterHelperReference

set combinedClipname to Clipname & " " & (counter as string)

tell application "Final Cut Pro" to activate

-- this section runs the actual activities in FCP.

tell application "System Events" to keystroke "e" using command down

delay 0.5

tell application "System Events" to keystroke "g" using command down & shift down

delay 0.5

tell application "Finder" to set the clipboard to shortPathToClipFolder as string

delay 0.5

tell application "System Events" to keystroke "v" using command down

delay 0.5

tell application "System Events" to keystroke return

delay 0.5

tell application "Finder" to set the clipboard to combinedClipname

delay 1

tell application "System Events" to keystroke "v" using command down

tell application "System Events" to keystroke return

set myFile to (PathToClipFolder & combinedClipname & ".mov")

-- compares the filesize of the new clip over time. As long s it increases it means that it's still rendering

delay 1

set Size_1 to size of (info for myFile) -- get initial size

delay 2

set Size_2 to size of (info for myFile)

repeat while Size_2Size_1 --if they don't equal, loop until they do

set Size_1 to size of (info for myFile) -- get initial size

delay 1

set Size_2 to size of (info for myFile)

end repeat

-- importing...

tell application "System Events" to keystroke "i" using command down

delay 1

tell application "System Events" to keystroke "g" using command down & shift down

tell application "Finder" to set the clipboard to myFile as string

delay 0.5

tell application "System Events" to keystroke "v" using command down

tell application "System Events" to keystroke return

tell application "System Events" to keystroke return

delay 0.5

tell application "System Events" to key code 21 using command down

delay 0.5

tell application "System Events" to keystroke return

delay 0.5

tell application "System Events" to key code 109 -- F10 key

end if

  • Create a shortcut with Keyboard Maestro to trigger the script.
Then
  • If you haven't already done so, set up a shortcut for exporting Quicktime movies in Final Cut. The script is made to use command + e. If you want to use a different shortcut, you have to change the script accordingly.

  • Dissable all but one videotrack.
  • Mark in and out points for the region you want to bake and replace.
Running the script:
  • Hit your shortcut
  • Choose an option from the list (if you made one)
  • Enter a name for the Clip(s)
  • Choose where to save them
  • Hit OK and wait until everything is done
I will also post a video soon. I figured video tutorials are just so much better, even if I sound like I'm falling asleep :D
So check back soon!