MCE Controller


Version 1.0.2 March 24, 2004


Copyright � 2004 Charles E. Kindel, Jr. All Rights Reserved.



This version of MCE Controller is distributed as freeware for non-commercial use. Donations of any value appreciated. Make donations using PayPal ( to If you want to use MCE Controller for a commercial purpose, contact me at for licensing information.


MCE Controller allows the Media Center application of Windows Media Center Edition (MCE) to be integrated into an advanced control system by enabling programmatic control of the user interface via a TCP/IP connection.


To put it simply, MCE Controller, allows you to simulate a press of any button on the MCE IR remote control by sending a text command to a TCP/IP port on the MCE machine. For example if MCEController receives the string �mypictures � it will tell Media Center to go to the �My Pictures� page.


This application was initially developed to enable integration of MCE into a Crestron whole-house audio/video system. However, it is general enough that it can be utilized from any control system that supports sending text strings to a TCP/IP port. Most control systems, such as Crestron or AMX, support IR emitting. For many applications, emitting the MCE IR commands will suffice. However, for some installations the reliability of IR emitting and other factors may make IR emitting problematic and MCE Controller offers a robust solution.


MCE Controller can act as either a TCP/IP client or server. When acting as a client the target host and port can be configured. When acting as a server the incoming port can be configured.


MCE Controller runs showing only a taskbar icon. By double clicking on the taskbar a status window is displayed that shows a log of all activity. You can also right-click on the taskbar icon for a menu.


See the Revision History below for details of what's new in this version.


Important Note: MCE Controller requires the .NET Framework 1.1. Use Windows Update to ensure you have this installed before running MCE Controller.


MCE Controller is a very simple application that does not require an installation program. The distribution ZIP file includes three files:





You are reading the first file, so you know what it does. MCEController.exe is the program executable and MCEControl.commands is an XML file that defines the commands MCE Controller will respond to and what actions it will take.


To install MCEController:

  1. Copy the MCEControl.exe and MCEControl.commands files to some directory on your machine (e.g. C:\Program Files\MCEControl). The MCEControl.commands file must be in the same directory as MCEControl.exe.
    If you are upgrading from a previous version and have modified MCEControl.commands you should compare your version of MCEControl.commands with the new one and update yours as appropriate.
  2. Create a shortcut in your startup directory that points to MCEControl.exe. Just accept all the defaults for the shortcut (e.g. DO NOT change the working directory or how the window is shown).


When MCEControl runs, it defaults to showing itself as only a taskbar icon. Double clicking on the taskbar icon will show the configuration/status window.


If you would like it to show it�s configuration/status window upon startup, uncheck the �Hide Window at Startup� checkbox in the settings dialog.


Note that all configuration settings are stored in a file that will be created in the program directory when MCE Controller is first run. The configuration settings file will be named MCEControl.settings .


You can run multiple instances of MCE Controller. To do so simply copy the EXE to a 2nd directory along with the .commands file. Each copy will have its own independent MCEControl.settings file.


MCE Controller can act as either a TCP/IP client or server (it can actually operate as both simultaneously, but it�s unlikely it would ever be useful to do so). By default MCE Controller is configured to act as a TCP/IP server listening on port 5150. You can change this behavior using the Settings dialog described below.


The Client Tab

The Client tab in the Settings dialog controls MCE Controller�s TCP/IP client functionality. When acting as a client, MCE Controller will repeatedly try to connect to the specified port on the specified host and wait for commands to be sent from the host. MCE Controller sends nothing to the host.

  • Enable Client. This checkbox enables or disables the TCP/IP client functionality. If enabled, the followings settings apply:
  • Host. This is the IP address or host name of the server MCE Controller is to connect to.
  • Port. This is the port that MCE Controller will connect to.
  • Reconnect Wait Time. This is the number of milliseconds (default is 20 seconds or 20000 ms) MCE Controller will wait before trying to reconnect to the host once a connection has been dropped or a connect fails.

The Server Tab

The Server tab in the Settings dialog controls MCE Controller�s TCP/IP server functionality.  When acting as a server, MCE Controller will open the specified port and wait for a client to connect. When a client does connect MCE Controller will wait for incoming commands until the client closes the connection.

  • Enable Server. This checkbox enables or disables the TCP/IP server functionality. If enabled, the followings settings apply:
  • Port. This is the port that MCE Controller will listen on.
  • Enable Wakeup. If enabled, MCE Controller will attempt to connect to the specified host/port, send the �Wakeup command� and disconnect when it first starts. When it shuts down it will send the �Closing command�. This functionality is useful when the remote client needs to be notified that MCE Controller is ready (for example after the MCE PC has rebooted).

Usage Notes

  • See the Included Commands section below and the contents of the MCEControl.commands file for a list of all of the commands MCEControl supports by default.
  • To test MCE Controller (in server mode) open a telnet session to whatever port MCE Controller is configured to open and type commands. For example telnet localhost 5150 followed by alttab and a carriage return will cause an �Alt-Tab� keystroke to be generated on the local system.
  • The mcestart command will launch Media Center and cause it to be maximized. If you do not want this behavior, change MCEControl.commands such that the mcestart command does not have the embedded nextCommand element.
  • For MCEContoller to work property the target application (Media Center ) must be the active window (foreground) on the desktop.  You can use the mceactivate command to cause Media Center to be the foreground app if it�s already running. Alternatively you can just use mcestart as it will end up causing the same thing to happen (although not as quickly).
  • Also, you may find that greenbutton is a better function than mcestart because it is equivalent to the green-button. mcestart is a bit different because if MCE is already running mcestart will not go to the "start" screen of MCE while greenbutton will. However, greenbutton does not cause the MCE window to be maximized.

Included Commands

The MCEControl.commands included with MCE Controller includes the following commands that can control Windows Media Center. See the section below for instructions on how to add, remove, or change these commands. Note that there are some other commands in MCEControl.commands text such as "notepad" which starts notepad.exe. These are there just for illustrative purposes.

Command Description
mcestart Launches the eHome shell and makes it the foreground, maximized window.
shutdown Causes the machine to shutdown.
restart Causes the machine to reboot.
standby Causes the machine to go into standby mode.
hibernate Causes the machine to go into hibernate mode.
mcemaximize Causes the eHome shell to maximize; ehshell must be running.
mceactivate Causes the eHome shell to be the active, foreground window; ehshell must be running.
maximize Maximizes the current foreground window.
alttab Performs an "Alt-Tab" task switch; useful for testing.
back Equivalent to the Back button on the MCE remote.
cc Equivalent to the closed caption button on the MCE remote.
ch+ Channel up.
ch- Channel down.
close Closes ehshell.exe.
delete Equivalent to the DEL key.
down Down arrow.
dvdaudio DVD audio menu.
dvdmenu DVD menu.
dvdsubtitle DVD subtitles.
end END key.
escape ESC key.
fwd FWD button >|
guide Guide button
help F1
home HOME key.
insert INS key.
left Left arrow.
livetv LiveTV button
greenbutton Equivalent to the green button. ehtray.exe must be running for this to work. ehtray.exe will be running after ehshell.exe runs the first time after boot, or you can put ehtray.exe in your startup folder.
moreinfo Detail/More-Info button
mute Mute button.
mymusic My Music button.
mypictures My Pictures button.
mytv My TV button.
myvideos My Videos button.
ok OK button
pause Pause button.
play Play button.
record Record button.
recordedtv Recorded TV button.
right Right arrow.
rew REW button (rewind)
tab Tab key
stop Stop button.
skipback Jump back
skipfwd Jump forward
vol- Volume down.
vol+ Volume up.
up Up arrow.

Extending MCE Controller

The MCE Controller code currently has no specific dependencies on Windows Media Center . All MCE specific data is encapsulated in the MCEControl.commands file found in the same directory as MCEControl.exe. Therefore, MCE Controller is actually a generic mechanism for exposing UI commands on the network. It already supports sending any message or keystroke and can launch arbitrary processes.


To utilize this functionality all you have to do is edit the MCEControl.commands file to suit your needs.


MCEControl.commands supports four types of commands: SendInput , SendMessage , StartProcess , Shutdown, and SetForegroundWindow :

  • SendInput commands send keystrokes. Any combination of shift, ctrl, alt, and left/right Windows keys can be used with any key code. See the winuser.h file in the Windows SDK for a definition of all standard VK codes. MCEController uses the SendInput ( ) API to send keystrokes. Keystrokes go to the foreground window. Use a SetForegroundWindow element to set the foreground window to the target app by specifying the app�s top-level window class name (e.g. �ehshell �).

    For example, the following causes a Ctrl-P to be send to the foreground window, and if that window is Media Center, the My Pictures page to appear:

    <SendInput Cmd="mypictures" vk="73" Shift="false" Ctrl="true" Alt="false" />

  • SendMessage commands are just that. They cause MCE Controller to send a Windows message using the SendMessage ( ) API to the foreground window if no class name is specified, or to a particular window if that window�s class is specified.

    For example, the following is equivalent to sending a WM_SYSCOMMAND with the SC_MAXIMIZE flag, causing the window with the class name of �ehshell� to be maximized (WM_SYSCOMMAND == 247 and SC_MAXIMIZE == 61488):

    <SendMessage Cmd="mce_maximize" ClassName="ehshell" Msg="274" wParam="61488" lParam="0" />

  • StartProcess commands start processes. Process commands support chaining using the nextCommand element. The embedded command will be executed after the started application starts processing windows� messages.

    For example, the following launches Media Center and maximizes it:
    <StartProcess Cmd="mce_start" File="C:\windows\ehome\ehshell.exe">
        <nextCommand xsi:type="SendMessage" ClassName="ehshell" Msg="274" wParam="61488" lParam="0" />

  • Shutdown commands can shutdown, restart, suspend, or hibernate the machine. The Type attribute determines the type of shutdown to perform. Type can be "shutdown", "restart", "suspend", "hibernate", and "abort". All are self explanatory except "abort" which, if issued within 30 seconds of issuing a "shutdown" or "restart" command will abort the shutdown. This example would cause the machine to go into standby mode.

    <Shutdown Cmd="standby" Type="standby"/>

    Note that MCE Controller has no way of causing a machine to "wake up". You can use Wake-On-LAN (WOL) to do this. You'll need to figure out a way to send the "WOL" magic packet from your control system to the MAC address of the Ethernet adapter in your MCE PC.
  • The SetForegroundWindow command sets the specified window (using the window�s class name) to the foreground.

    For example, the following makes Media Center the foreground Window (assuming Media Center is running):

    <SetForegroundWindow Cmd="mce_activate" ClassName="ehshell"/>


You can also edit MCEControl.commands to change the text string associated with a particular command.

Future Version Ideas

Below is a list of some of the things I�m considering adding to MCE Controller in the future. If you like these ideas, or have others that you�d like to see implemented, please send me email or post feedback on the MCE Controller website.

  • Windows MCE supports a technology that allows external applications to be notified of state changes within MCE. For example, what music track is currently playing, or what channel on live TV is currently active. MCE Controller could be enhanced to support relaying this state information over the network to other devices.
  • MCE Controller currently has about 20% the functionality of Girder. Given the current architectural model of MCE Controller, I could easily extend it to support much of what Girder can do such as scripting, supporting other input and output mechanisms, etc� I�ve toyed with the idea of turning MCE Controller into a Girder alternative for general purpose AV device integration.
  • An installation program.
  • Security. Right now there is no security on the port that MCE Controller opens when in server mode. If you are concerned about this you can use MCE Controller in client mode. I�ve considered adding security, however one of the reasons I wrote MCE Controller was that Girder�s iserver functionality requires the use of a security mechanism which makes it very hard to use from a control system such as Crestron�

Revision History

  • Version 1.0.1 (February 22, 2004) � First publicly released version.
  • Verison 1.0.2 (March 24, 2004) - New features:
    • Added support for system shutdown, restart, standby, and hibernate (the Shutdown command type).
    • Renamed a few commands ("mce_start" is now "mcestart" for example) to be more consistent.