MCE Remote: getting lazier by the day

Now that I’ve set up Plex on my server and install Plex Home Theater on my PC, I can play movies on my PC and watch them on the TV in the living room (via SPDIF & HDMI cables).

Trouble is Plex Home Theater is designed to be controled by a remote and mice are not supported.

I’ve therefore purchased an MCE remote from Amazon. The beauty of this remote is that 1) it’s ridiculously cheap (the price was £6.95 when I bought it) and 2) it’s natively supported by Windows, no need for bloat software or drivers.

Emprex 3009ARF Wireless MCE Remote Control

Emprex 3009ARF Wireless MCE Remote Control

1 tiny annoyance though, the green Windows button is set up to launch Windows Media Center and there doesn’t appear to be a setting to change this.

MCE Windows Button

MCE Windows Button

After a bit of digging online, I found out that the green button launches C:\Windows\ehome\eshell.exe

So it should then be fairly easy to replace this file and put my own script instead right?

Wrong! For some reason Windows has this file set up in  such a way that you cannot delete or rename it. This is the way to go round the limitation:

  1. Navigate to C:\Windows\ehome\
  2. Right-click on eshell.exe > Properties
  3. Click on the Security tab
  4. By default, TrustedInstaller has all rights and you cannot change the rights for other groups / users

    eshell Properties

    eshell Properties

  5. Click on Advanced > Owner tab > Edit.

    eshell Owner

    eshell Owner

  6. Select the new Owner (your account) and Accept > OK
  7. Now select your user and enable Full Control

You can now rename eshell.exe and use a different program instead.

I have used AutoHotKey to write a script which would launch Plex Home Theater instead of Windows Media Center:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
run, "C:\Program Files (x86)\Plex Home Theater\Plex Home Theater.exe"

 

Now why stop there?

I would still need to get to the PC and manually set the default audio output to SPDIF, and I have to use my HomeEasy remote to activate a Movies mood scene in DomotiGa (I’ve synced a button with my RFXTrx433 so DomotiGa recognises the remote as a device).

So I created another AuthoHotKey script which constantly runs in the background and adjusts the default audio output depending on whether Plex Home Theater is running or not. And it also executes a Python script which will send a command via JSON-RPC to update a device on  DomotiGa.

Here are the scripts:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

MCE_Win = 0
DetectHiddenWindows, On
while(1)
{
winwait, Plex Home Theater
winminimize, Plex Home Theater
run, "C:\Program Files\Python 3.5\python.exe" "C:\Program Files\Python 3.5\MoodSceneMoviesOn.py"
; Sets audio out to SPDIF
runwait, "E:\Docs Communs\G12.exe"
winactivate, Plex Home Theater
winmaximize, Plex Home Theater
MCE_Win = 1
sleep, 5000
while(MCE_Win)
{
IfWinNotExist, Plex Home Theater
MCE_Win = 0
sleep, 2000
}
run, "C:\Program Files\Python 3.5\python.exe" "C:\Program Files\Python 3.5\MoodSceneMoviesOff.py"
; Sets audio out to PC Speakers
run, "E:\Docs Communs\G8.exe"
}

 

import requests, subprocess
import json, json as simplejson

def Domotiga_API(Method, Device_Id, Valuenum, Value):
url = "http://192.168.0.24:9090" 
data={'jsonrpc': '2.0', 'method': '' + Method + '', 'params': {'device_id': Device_Id, 'valuenum': '' + str(Valuenum) + '', 'value': '' + str(Value) + ''}, 'id': 1}
headers = {'Content-type': 'application/json', 'Accept-Encoding': 'text/plain', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(data), headers=headers)
c = r.content
result = simplejson.loads(c)
#print result

Domotiga_API("device.set", 21, 1, "On")

Now I simply need to sit on the sofa and press the green button, and the following happens “automatically”:

  • Plex Home Theater starts
  • Default audio set to SPDIF on my Windows PC so the sound goes to the amplifier
  • Speakers connected to the server  announce “Mood Scene: Movies, Activated
  • The lights in the kitchen and living room turn off
  • A red light for the right ambiance gets turned on

Isn’t life beautiful? 🙂

[Edit – 20/05/2016] This doesn’t seem to work under Windows 10. MCE is technically dead under Windows 10, yet I can still start MCE manually and the remove appears to still send some of the commands, only nothing happens when pressing the MCE button. I’ll share more once I have an update