Script to control Windows Media Center (MCE)

Share your scripts written for the Script Device in this forum.
Post Reply
allanstevens
Member
Posts: 81
Joined: Thu Sep 01, 2005 7:56 am
Location: UK

Script to control Windows Media Center (MCE)

Post by allanstevens »

Attached is a script to control Windows Media Center from housebot. You will need MCE Controller running on the MCE pc for the script to work. This can be found here - http://www.kindel.com/Default.aspx?tabid=25

Full instructions in the hbx file.
Attachments
MCEControl.zip
(1.4 KiB) Downloaded 1756 times
Davieboy
Member
Posts: 30
Joined: Thu Jul 14, 2005 12:35 pm
Location: Ireland

Post by Davieboy »

Anyone have any joy on getting this working properly? I find that the script tries to open multiple telnet windows after multiple button presses on commands and therefore stops working
Image
allanstevens
Member
Posts: 81
Joined: Thu Sep 01, 2005 7:56 am
Location: UK

Post by allanstevens »

Davieboy,

Just updated the script, let me know how you get on with it. Thanks

Code: Select all

'Create object
set WshShell = CreateObject("WScript.Shell")
'Open Command Prompt
WshShell.Run "%SystemRoot%\system32\cmd.exe",2
'Loop until Command Prompt is ready
Do Until WshShell.AppActivate("cmd.exe")                               
Loop
'Send keys to command prompt to start telnet session REPLACE IP ADDRESS OF MEDIA CENTER PC
WshShell.SendKeys "telnet -e C 10.0.0.21 5150~"
'Get property from housebot and send to telnet session
WshShell.SendKeys GetPropertyValue("MCE Control.MCE Command")+"~"
'Closed session
WshShell.SendKeys "C"
'Close telnet
WshShell.SendKeys "quit~"
'Close Command prompt
WshShell.SendKeys "exit~"
'Release object
Set WshShell = Nothing 
allanstevens
Member
Posts: 81
Joined: Thu Sep 01, 2005 7:56 am
Location: UK

Post by allanstevens »

Have updated the script again, now using OstroSoft Winsock Component (http://www.ostrosoft.com/oswinsck.asp#lic). This script seems much more reliable and responsive.

Code: Select all

On Error Resume Next

Dim Conn
Dim oWinsock 'As OSWINSCK.Winsock

Set oWinsock = CreateObject("OSWINSCK.Winsock")
Conn = oWinsock.Connect ("10.0.0.21",5150)
oWinsock.SendData(GetPropertyValue("MCE Control.MCE Command")& vbCrLf )
oWinsock.CloseWinsock
Set oWinsock = Nothing

Set Conn = Nothing
Have also started working on c# app that use MediaCenter State API to get whats playing/recording/etc and using the ExternalControl updates a null device in HouseBot if anyone is interested?
Davieboy
Member
Posts: 30
Joined: Thu Jul 14, 2005 12:35 pm
Location: Ireland

Post by Davieboy »

I am very interested. Any help testing that u need please let me know via pm or on this page.
Image
allanstevens
Member
Posts: 81
Joined: Thu Sep 01, 2005 7:56 am
Location: UK

Post by allanstevens »

Davieboy,

Thanks for the offer. What version of Media Center do you use? I have it working on Vista, although I can't see any reason it would not work on MCE 2005.

Won't get much more coding done for the next week or so (Glastonbury :-) Hope to have something for testing at the end of the month. I'll pm you when it's ready - cheers.

App is based on the sample code here - http://www.mperfect.net/mceState/ Should give you an idea of what can be captured.
Davieboy
Member
Posts: 30
Joined: Thu Jul 14, 2005 12:35 pm
Location: Ireland

Post by Davieboy »

I am running both on dual boot so can test in both operating systems. Am running vista ultimate edition
Image
jonkjon
Member
Posts: 93
Joined: Thu Jul 19, 2007 4:52 pm

Post by jonkjon »

I would love to give this a try.... am trying the script now but so far no luck....I would be very interested in the c# app....

*Update* I discovered that media center has to be in the foreground to receive the sendkeys. That's what i was missing before. I am using the Ostrosoft component. If there were some way to get the status back from this, it will be terrific.....Good Job!
jonkjon
Member
Posts: 93
Joined: Thu Jul 19, 2007 4:52 pm

Post by jonkjon »

Got the MCEState app running and so far it is great. I was toying with the itunes script and in there, you can pass a playlist to the script. Is there some way that could be done with the mcecontrol's mcecommand? I need to find a way to display playlists on the software remote. If i could see the songs in the entire playlist and select the individual ones with the mcecommand property, i'd be in business......Again, this is GREAT!
jonkjon
Member
Posts: 93
Joined: Thu Jul 19, 2007 4:52 pm

Post by jonkjon »

It finally dawned on me that the mcecommands are just sendkeys. So i now see why there is no way to send a playlist. I abandoned this and went with the iTunes script along with my own script which parses an iTunes xml playlist. This allows me to at least see the songs that are in the playlist that is currently playing. I can of course use the navigation controls etc; to move from song to song......
Post Reply