Using EventGhost to Integrate a 3rd Party App with Your Front End

May 31 2009

 

EventGhost Logo

Most people in the HTPC community have a preferred media center application that handles 80% to 90% of the capabilities desired. Unfortunately, integrating an outside application to add functionality to your main front end and get to 100% seamless integration is not always easy. This is where automation tools can help. Automation tools are a class of software applications that can interperet inputs from many different sources, and then pass commands along to many other devices and applications. Let's look at how we can use automation tools to perfect the HTPC experience.

Girder is probably the most well known automation tool and it is well documented, with a large support community but runs $50 for the standard version. In hopes of avoiding the cost of Girder, I am going to look at using EventGhost (free as in beer) to smoothly integrate Blu-ray playback software with my media center front end. The goal is to be able to perform all actions with my remote control and seamlessly switch back and forth between applications, the same as if the third party application was integrated directly with the media center software. This write-up will use SageTV and Cyberlink PowerDVD 9 for the demonstartion, but hopefully the article will demonstrate how to do the same for any other media center front end and third party application. As I develop more EventGhost control files I will add them to the guide, giving you a starting point for your own integration.

Transition

 

What EventGhost Does

  

I generally dislike wasting my time rewriting specs, features, etc that are easily found on the website for a given product. The following is a direct cut and paste from the EvenGhost wiki and gives you a quick look at some of the capabilities of the product.

EventGhost is an open-source automation tool for MS Windows, that can be extended through plugins. It can use different input devices like infrared or wireless remotes to trigger macros, that on their part control a computer and its attached hardware. After the user has configured everything to its needs, the program will run silently in the system tray and waits for an event to arrive. So it can be used to control a Media-PC with a normal consumer remote for example.

Other common things that can act as a trigger for an event are:

  • key presses (hotkeys)
  • joysticks/gamepads
  • a program is starting or is switched to by the user
  • another program like EventGhost (on another PC), Girder or Netremote is sending an event through TCP/IP
  • a special HTTP request is made to the internal web server
  • another program is sending an event through ActiveX

EventGhost gives the user a GUI to configure macros that do all kind of things like:

  • launching applications
  • emulating keystrokes
  • emulating mouse movements and clicks
  • control the soundcard
  • move, resize, etc. windows on the desktop
  • execute Python scripts (Python interpreter and editor is built-in)
  • transmit IR-codes to external consumer equipment, if you have a supported IR-transceiver.
  • control external hardware devices like projectors and other media equipment through RS232 communication
  • extensive control of programs, that have special communication interfaces, like some media players

The real power comes from creating innovative combinations of the events and triggers to control or automate things that you were unable to before.

 

Initial Configuration and Adding Plugins

When configuring EventGhost it is important to have in mind the end result that you want to achieve. Here are the goals I have in mind for this guide:

Objective: Seamlessly control and switch between SageTV and a Third Party Application (Cyberlink PowerDVD 9)

  • Take input from my Harmony remote via a USB-Uirt
  • Control SageTV when in focus
  • Control Cyberlink PowerDVD when in focus
  • Switch between SageTV and Cyberlink PowerDVD

 

Getting started, the first step is to download and install EventGhost . Once the software is installed and running you will see the following screen:

First Install

On the left is a log of events, and on the right is the current configuration file that you are working with. 

EventGhost uses plugins to load specific functionality, auto add groups of events, control external hardware, and provide a number of other miscellaneous, plugin specific capabilities. By default only the most essential plugins are auto loaded. These four essential plugins are EventGhost Core, Mouse, System, and Window. Alone they provide a signifcant level of control capability. However to add greater control, easier setup of applications, and access to external hardware another 70+ plugins. Convienently included in EventGhost are plugins for the USB-Uirt, SageTV, and Cyberlink PowerDVD. These should make setting up our first third party application quite easy. Later we'll take a look at what you can do when no plugin exists for you application. The additional plugins you need must be added to the configuration. EventGhost only loads those capabilities you require when it runs.

Add Plugin

Plugins are added through Configuration Menu -> Add Plugin. Here you see me selecting the plugin for my USB-Uirt. Some plugins will give you further configuration options once you install them.

To make the rest of the setup easier, we're going to install a few more plugins that preload some capabilities and predefined application events. These are all the plugins I need to add:

  • USB-Uirt (or whatever IR/Other reciever you use) - for accepting remote inputs
  • SageTV - preloads all the SageTV commands
  • Cyberlink PowerDVD - preloads all the PowerDVD commands
  • Task Create/Switch Event- monitors tasks performed by computer

The SageTV plugin and Cyberlink PowerDVD plugin create a folder full of commands for controlling the two respective application. These are really just time savers and you could just as easily add the commands you need one at a time. Later we're going to put each applications set of commands in a Context Folder, but for now they must be created at the highest level of the tree when you are asked for the location to place their folders.

ADDED: Links to XML That Auto Creates Folder with Commands
Hulu Desktop

All you need to do is copy and paste the XML from my blog into your saved EventGhost file. Just close EventGhost and open your save file in any text editor. Just scroll down and find the end of an existing folder and paste in the XML provided.

 

Creating Macros and Setting Up Exclusive Mode

At this point you should have two folders, SageTV and CyberLink PowerDVD, that are full of commands. However, if you are setting up the control of a third party application that does not have a plugin, then you need to create the commands necessary to control it one at a time. These commands are called macros. They consist of the action the macro will perform and the event that will cause the macro to execute. I would recommend storing all the macros for control of an application in a folder. We then create a folder called Context Folder, and move all the folders for each application into the Context Folder. Our setup should now look like this:

 

Context Folder

 

You can see on the left that each plugin appears under Autostart. These will all run automatically on opening the program. You can also see the Context Folder I created and the two folders full of macros for SageTV and PowerDVD. Inside of the Left macro there is the single line: SageTV: Left. This is the action that will be exectued when that macro is run. We still need to map the event that will trigger the macro later. You can add your own macros by going to Configuration Menu -> Add Macro.

We are now going to add our own macros for switching control between the two applications. We will need to add two macros to do this. Both of these macros trigger the same action: EventGhost -> Exclusive enable a folder/macro. This action will enable only a single folder or macro out of a group of folders/macros that are at the same hierarchy level in the tree, and disable all the rest. 

Exclusive Events

Above you can see the two new macros I added that will be used to assign exclusive use of the remote control to a single application.

 

Adding Events to Trigger Actions

Now we need to associate events that occur with the macros that we want them to trigger. These events can be many different things, but there are a few specific ones that I will use for trigger the commands we've set up. The two types of events I will use are IR codes recieved by the USB-Uirt, and also the open and close of a third party application. The Task Create/Switch Event plugin that was added supports the ability to monitor the opening and closing of applications. Combined with the ability of SageTV to launch a third party application, EventGhost can monitor for the application to open, switch control to the third party app, wait for third party app to close, and when it does switch control back over to SageTV.

Let's start with the remote control events. While EventGhost is running, just point your remote at your IR reciever and press the button you want to assign to a macro. You should see a little lighting bolt followed by an IR code show up in the log. This represents an event. You can now drag and drop this event to the macros you want to associate with the button press on your remote.

Associate Event

Now let's setup the opening, close, and exclusive use of the IR reciever by PowerDVD. I'm using SageTV as my front end. This allows me to easily add a menu item that launches an external application. I can also configure it to sleep SageTV while the external app is open and to reopen full screen when the third party app closes. This is illustrated below. I did need to add one command to the Cyberlink plugin's preloaded commands. There didn't exist a macro to close PowerDVD, so I added a new macro that on the use of my 'Exit/Back' button would execute the Window -> Close action.

Open and Close Events

Finally, we will assign the open and closing events of PowerDVD to trigger the exclusive control macros. These events now show up in my log since I tested SageTV's ability to properly open PowerDVD. Just drag them over to the macros and you should be all set. We have now setup EventGhost to monitor for Cyberlink's PowerDVD to open and redirect remote control events to the controlling of PowerDVD until it closes.

EDIT: I played around with the various different events that you might use to drive the decision about which program is currently the active program. I found that relying on any of Task.Deactivated events was very unreliable. Instead the best choice is to always use Task.Activated events. Task.Created was also no good, because if a program stayed in memory, Windows didn't always "Create" it the next time I switched to that application. Currently I have EventGhost managing control of SageTV, PowerDVD 9, and Hulu Desktop. The events I use to enable exclusive mode are:

SageTV - Task.Activated.SageTV
Cyberlink PowerDVD 9 - Task.Activated.PowerDVD9
Hulu Desktop - Task.Activated.HuluDesktop

Concluding Remarks

My computer finally has the fully integrated Blu-ray playback that I've been too lazy to get set up. This was really much easier than I expected and I will proceed to add many more applications this weekend. Those apps that don't have plugins, I'll probably set up to use keyboard press events and see how reliable that is. I can't beleive I've spent months fooling around with my keyboard and mouse for Blu-ray playback when this is really quite straightforward.

There are also a number of other capabilities provided. I know one that intirgues me is sound card/display card control. This could make it much easier to possibly swith sound modes, or sampling rates to match material, refresh rates, resolutions, or multi-monitor on/off. I'll have to look more into the other capabilities that EventGhost has and figure out what kind of useful abilities it has. Thanks to the folks that work on the EventGhost Project for developing this great alternative automation tool.

Website design by Yammm Software
Powered by Drupal