PDA

View Full Version : I made a Salling Clicker script for BOXEE



MasterZap
November 11th, 2008, 09:01 AM
If anyone is using the Salling Clicker (http://www.salling.com/Clicker/mac/) mobile phone app to control your computer over BlueTooth, I started to write a script for controlling Boxee from it. It's not quite complete at the moment, but if anyone is a Salling Clicker user and want the script, let me know and I'll post it here when it's in a more "usable" state....

The question is, what kind of AppleScript interface does Boxee have? Anything?

/Z (busy flicking through his movies with his Nokia N95) ;) :D

agentlame
November 11th, 2008, 10:36 AM
The question is, what kind of AppleScript interface does Boxee have? Anything?

none. boxee is cross-platform, so adding applescript support would disturb the platform independent nature of the code.

internally, boxee has it's own python interpreter. but this is used for plugins/addons.

to my knowledge, boxee does not offer an automation ain on any platform. i think it's something the devs should consider. but if they did add it, i suspect it would be in python, not applescript.

MasterZap
November 11th, 2008, 11:52 AM
none. boxee is cross-platform, so adding applescript support would disturb the platform independent nature of the code.

I figured as much. It would be neat w. programmability.

Right now, my Clicker script simply emulates keypresses, which gets you 95% of the way there... however, Salling Clicker *does* support much more advanced stuff like that (I can browse songs in iTunes on the phone via it, just as a small example).



internally, boxee has it's own python interpreter. but this is used for plugins/addons.

to my knowledge, boxee does not offer an automation ain on any platform. i think it's something the devs should consider. but if they did add it, i suspect it would be in python, not applescript.

Python would be fine, since it's all just about sending messages back and forth between the applescript and the python part anyway.

But this is actually good news for me, because it means my script is much more finished than I thought - since you really can't DO much more.... :D

/Z

premiumblend
December 2nd, 2008, 11:58 AM
I'd love to have a copy of that script.

You've got a PM waiting :)

MasterZap
December 5th, 2008, 08:03 AM
Well, the script is very trivial, and could be extended in many ways, since there are many interesting keyboard shortcuts one could map to phone keys... but itīs also trivially extended, so feel free to do whatever with it...



property kReturnKeycode : 2 * 16 + 4
property kRightKeycode : 7 * 16 + 12
property kLeftKeycode : 7 * 16 + 11
property kUpKeycode : 7 * 16 + 14
property kDownKeycode : 7 * 16 + 13
property kEscKeycode : 3 * 16 + 5
property kCommandKeycode : 3 * 16 + 7
property kTabKeycode : 3 * 16

property keymap_info : {{key_code:"s", key_title:"Play/Pause", key_description:""}, {key_code:"<", key_title:"Rew", key_description:""}, {key_code:">", key_title:"Fwd", key_description:""}, {key_code:"^", key_title:"+", key_description:""}, {key_code:"v", key_title:"-", key_description:""}, {key_code:"f", key_title:"Menu", key_description:""}, {key_code:"*", key_title:"Fullscreen", key_description:""}}

using terms from application "SEC Helper"

on process invoke a_terminal
if not my is_application_launched() then
tell application "Boxee"
launch
end tell
end if

tell application "Boxee"
activate
end tell

tell a_terminal
set my_keypad to make new keypad screen
set title of my_keypad to "B O X E E"
tell my_keypad
make new text row with properties {horizontal alignment:center, font size:medium}
end tell
push my_keypad
end tell
end process invoke

on update keypad the_keypad
set textual content of the first text row of the_keypad to "Use the directional controls and the Menu button to navigate. # for Help"
end update keypad

on process screen exit the_screen
end process screen exit

--
-- Key handling
--

on process key down the_key sent from the_keypad
if the_key is "#" then
show keypad help keymap keymap_info title "B O X E E Remote Help"
else if the_key is "s" then
simulate keyboard virtual down keycode kReturnKeycode
else if the_key is ">" then
simulate keyboard virtual down keycode kRightKeycode
else if the_key is "<" then
simulate keyboard virtual down keycode kLeftKeycode
else if the_key is "^" then
simulate keyboard virtual down keycode kUpKeycode
else if the_key is "v" then
simulate keyboard virtual down keycode kDownKeycode
else if the_key is "f" then
simulate keyboard virtual down keycode kEscKeycode
else if the_key is "*" then
simulate keyboard virtual down keycode kTabKeycode
end if
return true
end process key down

on process key up the_key sent from the_keypad
if the_key is "s" then
simulate keyboard virtual up keycode kReturnKeycode
else if the_key is ">" then
simulate keyboard virtual up keycode kRightKeycode
else if the_key is "<" then
simulate keyboard virtual up keycode kLeftKeycode
else if the_key is "^" then
simulate keyboard virtual up keycode kUpKeycode
else if the_key is "v" then
simulate keyboard virtual up keycode kDownKeycode
else if the_key is "f" then
simulate keyboard virtual up keycode kEscKeycode
else if the_key is "*" then
simulate keyboard virtual up keycode kTabKeycode
end if
return true
end process key up

end using terms from

on is_application_launched()
tell application "SEC Helper"
set the process_flag to check application availability "Boxee"
end tell
if the process_flag then
return true
end if
return false
end is_application_launched


Naturally, it requires that you have the Salling Clicker app on your phone and on your mac, and that you create a new empty script from the Salling Clicker UI that you name Boxee and basically paste in all the above using the script editor...

/Z

tastyavocado
December 10th, 2008, 06:09 PM
thanks for the script, works fine

FelipeCamus
January 26th, 2009, 09:04 PM
thanks for the script, works fine,
but is it possible to add the ability to control the system volume with the numbers of the phone?
, for example 1 and 7 or 8 and 0, to move the volume up and down independently of the screen you are?
Thank`s alot

chrisward
February 1st, 2009, 02:11 PM
How do I make a script? Can't seem to find it on the ui.

chrisward
February 1st, 2009, 02:22 PM
Windows user, different script language?

broadcast_techie
April 4th, 2010, 08:13 AM
I've added a few bits to the script, including system volume control:
(Note - I've just hacked it in, no real debugging / no real thought. Please tidy it up!)


property kReturnKeycode : 2 * 16 + 4
property kRightKeycode : 7 * 16 + 12
property kLeftKeycode : 7 * 16 + 11
property kUpKeycode : 7 * 16 + 14
property kDownKeycode : 7 * 16 + 13
property kEscKeycode : 3 * 16 + 5
property kCommandKeycode : 3 * 16 + 7
property kTabKeycode : 3 * 16


property keymap_info : {{key_code:"s", key_title:"Play/Pause", key_description:""}, {key_code:"<", key_title:"Rew", key_description:""}, {key_code:">", key_title:"Fwd", key_description:""}, {key_code:"^", key_title:"+", key_description:""}, {key_code:"v", key_title:"-", key_description:""}, {key_code:"f", key_title:"Menu", key_description:""}, {key_code:"*", key_title:"Fullscreen", key_description:""}, {key_code:"3", key_title:"Sys vol up", key_description:""}, {key_code:"6", key_title:"Sys Vol down", key_description:""}, {key_code:"9", key_title:"Sys vol Mute", key_description:""}}


using terms from application "SEC Helper"



on process invoke a_terminal
if not my is_application_launched() then
tell application "Boxee"
launch
end tell
end if



tell application "Boxee"
activate
end tell



tell a_terminal
set my_keypad to make new keypad screen
set title of my_keypad to "B O X E E"
tell my_keypad
make new text row with properties {horizontal alignment:center, font size:medium}
end tell
push my_keypad
end tell
end process invoke



on update keypad the_keypad
set textual content of the first text row of the_keypad to "Use the directional controls and the Menu button to navigate. # for Help. 2 for play/pause"
end update keypad



on process screen exit the_screen
end process screen exit



--
-- Key handling
--



on process key down the_key sent from the_keypad
if the_key is "#" then
show keypad help keymap keymap_info title "B O X E E Remote Help"
else if the_key is "s" then
simulate keyboard virtual down keycode kReturnKeycode
else if the_key is ">" then
simulate keyboard virtual down keycode kRightKeycode
else if the_key is "<" then
simulate keyboard virtual down keycode kLeftKeycode
else if the_key is "^" then
simulate keyboard virtual down keycode kUpKeycode
else if the_key is "v" then
simulate keyboard virtual down keycode kDownKeycode
else if the_key is "f" then
simulate keyboard virtual down keycode kEscKeycode
else if the_key is "*" then
simulate keyboard virtual down keycode kTabKeycode
else if the_key is "3" then
simulate keyboard special key volume up
else if the_key is "6" then
simulate keyboard special key volume down
else if the_key is "9" then
simulate keyboard special key toggle mute
else if the_key is "2" then
simulate keyboard virtual down keycode 49


end if
return true
end process key down



on process key up the_key sent from the_keypad
if the_key is "s" then
simulate keyboard virtual up keycode kReturnKeycode
else if the_key is ">" then
simulate keyboard virtual up keycode kRightKeycode
else if the_key is "<" then
simulate keyboard virtual up keycode kLeftKeycode
else if the_key is "^" then
simulate keyboard virtual up keycode kUpKeycode
else if the_key is "v" then
simulate keyboard virtual up keycode kDownKeycode
else if the_key is "f" then
simulate keyboard virtual up keycode kEscKeycode
else if the_key is "*" then
simulate keyboard virtual up keycode kTabKeycode
else if the_key is "2" then
simulate keyboard virtual up keycode 49
end if
return true
end process key up



end using terms from


on is_application_launched()
tell application "SEC Helper"
set the process_flag to check application availability "Boxee"
end tell
if the process_flag then
return true
end if
return false
end is_application_launched