How to: Build your own app launcher for Windows Media Center
Recently I built and posted a little app that would let you launch Google TV Spotlight in Chrome from within Media Center and then returns to Media Center when Chrome closes. Several people have asked how I created the app so I thought it was time to do a write up. Note, this is for Windows 7.
For this project we’ll make another launcher to launch straight into Clicker.tv in Google Chrome. I’m going to assume you have already set up Windows Media Center and have installed Google Chrome.
First you need to download AutoIt here http://bit.ly/hV1xun. AutoIt is the magic that lets you create the executable. If you aren’t a programmer, don’t worry, this script is pretty basic and if you want to modify it there is really only a couple places to change. Once you download AutoIt, go ahead and install it.
Next you need the URL you want to open in Chrome. For this example it will be http://tv.clicker.com/
I like to put the whole project in a folder named for what I am launching. In your documents or where ever you want create a folder called ClickerTv.
If you want to make the button in Media Center pretty you’ll need a graphic representing your app. You can often get one of these from the web page or by doing search on Google or Bing Images. If you don’t have a graphic then the name you use shows up in the box in Media Center. If you have an image call it clickertv.jpg and put it into your clickertv folder.
The first thing you need to create is the clickertv.au3 file. au3 is the special extension that AutoIt uses. You can create this file with Notepad. I’ve included clickertv.au3 in the download at the end of this tutorial but here it is to show you what is in it. It is really just 4 lines of code. The rest is just comments to help you understand what is going on. clickertv.au3 should be put into your clickertv folder.
$temp = EnvGet(“localappdata”)
Run($temp&”\Google\Chrome\Application\chrome.exe –kiosk http://tv.clicker.com/”, $temp&”\Google\Chrome\Application”, @SW_MAXIMIZE)
ProcessWaitClose(“chrome.exe”)
Run(@WindowsDir&”\ehome\ehshell.exe”,@WindowsDir&”\ehome”)
So, what is all that about?
Line 1: Get the path to local appdata. This is done this way because it is variable on different machines as
it equates to a path like C:\Users\<username>\AppData\Local and since I don’t know your user name I use this method.
Line 2: Has several parts. First we set the path to chrome.exe. A standard install of Chrome puts this in
C:\Users\<username>\AppData\Local\Google\Chrome\Application\ which is why we needed line 1.
The –kiosk switch is necessary to launch Chrome in a full screen environment. Down side is you need to do alt+f4 to close
the application because you don’t get any controls to click on.
The next bit is the URL you want to open.
After the first comma we create the path the ‘Start in’ location. In this case, where chrome.exe is.
At the end, @SW_MAXIMIZEensures the application opens maximized. I leave this in even though we used the kiosk switch.
Line 3: This is a special AutoIt wait process that monitors whether chrome.exe has been closed.
Line 4: If chrome.exe is closed then line 4 is executed. This launches ehshell.exe from inside windows\ehome.
NOTE: Detailed explanation of the Run command can be found here: https://www.autoitscript.com/autoit3/docs/functions/Run.htm
If these paths aren’t working for you then you could find the exact paths to these files are on your system and use them instead
of the variables as I have done here.
Save your clickertv.au3 file. You can the right+click on it and click Run Script. If it works right you can right+click on it again and click Compile. Compiling will automatically create clickertv.exe. This file should automatically be created in your clickertv folder if you followed along above.
Next we need to create a file called clickertv.mcl. Again, I’ve included this in the zip file below. It is essentially and xml file that provides the code behind the Media Center button that calls the launcher. clickertv.mcl is created in your clickertv folder with Notepad and it contains the following lines:
<application run=”C:\Users\Public\Documents\clickertv.exe”
Name = “Clicker TV”
bgcolor=”RGB(0,0,0)”
startimage=”C:\Users\Public\Documents\clickertv.jpg”
thumbnailImage=”"
sharedviewport=”false” />
</application>
This is fairly straight forward.
Line 1 is the path to your exe file.
Line 2 is the name of the application within Media Center
Line 4 is the path to the jpg graphic
The rest is necessary code we don’t need to mess with.
Ok, so if you’ve lasted this far, in your clickertv folder you will have: clickertv.au3, clickertv.exe, clickertv.jpg, and clickertv.mcl.
Now you need to copy the files to their appropriate places. This is done by the install.bat file I included in the download but if you created a new launcher for something else you’ll need to know what goes where:
copy clickertv.exe to C:\Users\Public\Documents
copy clickertv.jpg to C:\Users\Public\Documents
copy clickertv.mcl to “%appdata%\Media Center Programs” This is the only tricky one. This folder equates to C:\Users\<username>\AppData\Roaming\Media Center Programs. You should actually be able to open it by opening up Computer and pasting in %appdata%\Media Center Programs into the address bar a the top and then pressing Enter.
That’s it! Now launch Windows Media Center and you should see a new entry for Clicker TV in your Extras Library.
Hopefully this was helpful to someone. If you create a launcher for something cool please share it with me!
Downoad clickertv.zip