Page 1 of 1

Script to control Windows Media Center (MCE)

Posted: Wed Jan 24, 2007 11:49 am
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.

Posted: Thu Feb 01, 2007 5:12 pm
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

Posted: Fri Feb 02, 2007 12:15 pm
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 

Posted: Fri Jun 15, 2007 4:06 am
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?

Posted: Fri Jun 15, 2007 8:38 am
by Davieboy
I am very interested. Any help testing that u need please let me know via pm or on this page.

Posted: Mon Jun 18, 2007 8:23 am
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.

Posted: Mon Jun 18, 2007 11:15 am
by Davieboy
I am running both on dual boot so can test in both operating systems. Am running vista ultimate edition

Posted: Thu Sep 06, 2007 6:55 pm
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!

Posted: Fri Sep 07, 2007 9:08 am
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!

Posted: Sun Sep 09, 2007 4:07 pm
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......