GarageBand - Bluetooth remote control for Sony T68i

Mar 17, '04 09:48:00AM

Contributed by: Anonymous

Here is a script to use with Salling Clicker 2.0, which will let you control GarageBand with your Sony T68i. This is especially helpful when you want to record something and you are in another room , having a beer and can't be bothered running back & forth to your Mac to press record & stop. All you have to do is go into Salling Clicker, in the System Preferences. Under "Clicker items" / Scripts, choose "New Category" by using the action button. Name this "GarageBand," then under that Category select "new script" by using the action button. Select "Keypad widget" - name it "GarageBand" also, and then press control while clicking on this new script to edit it with Script Editor.

Finally, replace the script you see in Script Editor with my Garage Band AppleScript. Save it, then drag the script from " Scripts" over to " Clicker items". This puts it in your phones "Accessories" menu. Read the rest of the hint for the script...

[robg adds: I can't test this one, as I have no Bluetooth phone ... and I apologize for the width of the code in the remainder of the hint, but there's not a good way to easily break the longer lines.]

Controls:

property soiko : "Stop"
property keymap_info : {¬
  {key_code:"s", key_title:"Play/Stop", key_description:"Toggles between play and stop."}, ¬
  {key_code:"<", key_title:"Rewind", key_description:"Moves the song pointer to the previous bar. Keeps moving when you hold the button."}, ¬
  {key_code:">", key_title:"Forward", key_description:"Moves the song pointer to the next bar. Keeps moving when you hold the button."}, ¬
  {key_code:"c", key_title:"Delete", key_description:"Delete the highlighted selection"}, ¬
  {key_code:"*", key_title:"Record", key_description:"Starts recording."}, ¬
  {key_code:"1", key_title:"Previous Event", key_description:"goes to the next recorded event."}, ¬
  {key_code:"0", key_title:"Return", key_description:"Return."}, ¬
  {key_code:"8", key_title:"New Track", key_description:"New Track."}, ¬
  {key_code:"7", key_title:"Save", key_description:"Save."}, ¬
  {key_code:"3", key_title:"Next Event", key_description:"Selects previous recorded event."}, ¬
  {key_code:"^", key_title:"Previous track", key_description:"Select previous track."}, ¬
  {key_code:"v", key_title:"Next track", key_description:"Select next track."} ¬
    }

tell application "SEC Helper"
  enter keypad mode text "GarageBand" & return & "(# for help)"
end tell

on key_was_depressed(keyCode)
  tell application "GarageBand"
    activate
  end tell
  if keyCode is ">" then
    tell application "SEC Helper"
      simulate keyboard virtual keycode 124
      show screen message "Forward" duration 2.5
    end tell
  else if keyCode is "<" then
    tell application "SEC Helper"
      simulate keyboard virtual keycode 123
      show screen message "Rewind" duration 2.5
    end tell
  else if keyCode is "^" then
    tell application "SEC Helper"
      simulate keyboard virtual keycode 126
      show screen message "Previous track" duration 2.5
    end tell
  else if keyCode is "v" then
    tell application "SEC Helper"
      simulate keyboard virtual keycode 125
      show screen message "Next track" duration 2.5
    end tell
  else if keyCode is "1" then
    tell application "SEC Helper"
      simulate keyboard virtual keycode 123
      show screen message "Previous Event" duration 2.5
    end tell
  else if keyCode is "7" then
    tell application "SEC Helper"
      simulate keyboard virtual keycode 1 modifiers {"command"}
      show screen message "Save" duration 2.5
    end tell
    
  else if keyCode is "0" then
    tell application "SEC Helper"
      simulate keyboard virtual keycode 36
      show screen message "press return" duration 2.5
    end tell
  else if keyCode is "8" then
    tell application "SEC Helper"
      simulate keyboard virtual keycode 45 modifiers {"command", "option"}
      show screen message "New Track" duration 2.5
    end tell
  else if keyCode is "3" then
    tell application "SEC Helper"
      simulate keyboard virtual keycode 124
      show screen message "Next Event" duration 2.5
    end tell
  else if keyCode is "s" then
    if soiko is "Stop" then
      tell application "SEC Helper"
        push keypad text "GarageBand" & return & "playing..."
        simulate keyboard virtual keycode 49
      end tell
      set soiko to "Play"
    else if soiko is "Play" then
      tell application "SEC Helper"
        push keypad text "GarageBand" & return & "stopped"
        simulate keyboard virtual keycode 49
      end tell
      set soiko to "Stop"
    end if
  else if keyCode is "c" then
    tell application "SEC Helper"
      push keypad text "GarageBand" & return & "selection deleted"
      simulate keyboard virtual keycode 51
    end tell
    set soiko to "Stop"
  else if keyCode is "*" then
    tell application "SEC Helper"
      push keypad text "GarageBand" & return & "recording..."
      simulate keyboard virtual keycode 15
      show screen message "Record" duration 2.5
    end tell
  else if keyCode is "#" then
    tell application "SEC Helper"
      show keypad help keymap keymap_info title "GarageBand Help"
    end tell
  end if
end key_was_depressed

on key_is_repeating(keyCode)
  try
    tell application "GarageBand" to activate
    if keyCode is ">" then
      tell application "SEC Helper"
        simulate keyboard virtual keycode 124
      end tell
    else if keyCode is "<" then
      tell application "SEC Helper"
        simulate keyboard virtual keycode 123
      end tell
    else if keyCode is "^" then
      tell application "SEC Helper"
        simulate keyboard virtual keycode 126
      end tell
    else if keyCode is "v" then
      tell application "SEC Helper"
        simulate keyboard virtual keycode 125
      end tell
    end if
    set repeatTimes to (repeatTimes + 1)
  on error
    beep
  end try
end key_is_repeating

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040313031413168