Script to control Windows Media Center (MCE)
-
- Member
- Posts: 81
- Joined: Thu Sep 01, 2005 7:56 am
- Location: UK
Script to control Windows Media Center (MCE)
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.
Full instructions in the hbx file.
- Attachments
-
- MCEControl.zip
- (1.4 KiB) Downloaded 1802 times
-
- Member
- Posts: 81
- Joined: Thu Sep 01, 2005 7:56 am
- Location: UK
Davieboy,
Just updated the script, let me know how you get on with it. Thanks
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
-
- Member
- Posts: 81
- Joined: Thu Sep 01, 2005 7:56 am
- Location: UK
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.
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?
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
-
- Member
- Posts: 81
- Joined: Thu Sep 01, 2005 7:56 am
- Location: UK
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.
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.
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!
*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!
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!
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......