2010-10-22, 02:35
Inspiration and improvements from post located here. Thanks thesuffering! (This thread is a continuation from thesuffering's thread. Use it as reference as needed.)
I've been trying to integrate Hulu Desktop into XBMC but I kept having problems. After tearing my hair out for a few days and after finding thesufferings work and making a few changes, I now have something I'm happy with.
Alright, here we go!
The Problem - When selecting Hulu Desktop from XBMC, Hulu would load in the background and never get focus. This post fixes that problem.
Programs used - AutoHotKey, EventGhost, XBMC, Hulu Desktop.
I've attached a photo so please reference that for the list below.
Starting with AutoStart, my HTPC opens EventGhost at startup, then EventGhost is what starts everything else for me.
AutoStart
Start Program: CPWizard.exe - CPWizard is a program I use to display MAME information when I play my arcade games.
Plugin: Directory Watcher - It's used to watch a folder when I download TV Shows. Article on this setup is here.
Plugin: Directory Watcher #2 - Disregard, it needs to be deleted as it currently has no function.
Plugin: XBMC - Plugin which gives me XBMC macros.
Plugin: Task Create/Switch Events - Keeps track of events from apps that you open and close and allows you to run macros after any event that you choose.
Continued Startup
After CPWizard - I was having issues with CPWizard. Initially I had CPWizard and XBMC in the Autostart above but CPWizard would load AFTER XBMC and for whatever reason, it would minimize XBMC. I would then have to grab my mouse and select XBMC from the Task Bar to open it/give it focus.
This is where the Plugin: Task Create/Switch Events comes into play. When CPWizard opens, it also minimizes and the event when it minimizes is Task.ClosedWindow.CPWizard so I told EventGhost that when it notices CPWizard minimize, to start XBMC. Doing so fixed the minimizing of XBMC.
The next two lines are for TED (Torrent Episode Downloader). TED is java based and JAVA kept crashing on my system when I started TED too early. What I did was created a 30 sec wait, after XBMC has loaded, to launch TED. It launches in the background and never messes with XBMC.
Launching Hulu
The problem with Hulu was it not focusing. You would select it from your list on XBMC, it would change to Hulu for a fraction of a sec and then it would come back to XBMC. This is what I did:
Focus Hulu
Launching Hulu - Using the Task Create/Switch Events plugin, I set the Task.Created.HuluDesktop event so that when EventGhost sees that event, it launches any macros after it and in this case, it's Quitting XBMC. The Quit XBMC macro can be found in the XBMC Plugin.
This didn't fix all my problems, only half. It quits XBMC but I still had issues with the focus. Even though it seemed Hulu Desktop was in the foreground, it wasn't, Windows was. I would need to click on Hulu Desktop before I would be able to control it with my remote. In order to fix it, the next macro needs to run.
Giving Focus to Hulu - The previous macro quits XBMC and one of the events created is Task.Destroyed.XBMC. When EventGhost sees that, it starts the program FocusHulu.exe. FocusHulu.exe is a compiled and modified version of the AHK script thesuffering (OP) had running in the background. Even though it worked, it had it's issues. The script was in a constant loop in the background and it didn't allow you to quit XBMC without it reopening it a second later.
Copy the following script into notepad and make sure it has the ahk extension.
I tried running the ahk script through EventGhost but I kept getting errors. What I did instead was compile it with the compiler(Ahk2exe) found in Compiler folder of AutoHotKey. When you open ahk2exe, select the script and then from the File menu, select convert. Once finished, you'll have an executable! The beauty of this, if you haven't figured it out yet, is that it only runs when XBMC quits and if you decide quit XBMC, for any reason,, the script will run but since Hulu Desktop is not running, it won't have anything to activate, so it does nothing. It only focus on Hulu Desktop when you run Hulu Desktop. And now for the last part.
Launching XBMC after Quitting Hulu - When EventGhost notices you closing Hulu (Task.Destroyed.HuluDesktop), it runs the Start Program macro for XBMC. The rest, as they say is history!
Any questions let me know.
I've been trying to integrate Hulu Desktop into XBMC but I kept having problems. After tearing my hair out for a few days and after finding thesufferings work and making a few changes, I now have something I'm happy with.
XBMC and Hulu playing nice - YouTube
Alright, here we go!
The Problem - When selecting Hulu Desktop from XBMC, Hulu would load in the background and never get focus. This post fixes that problem.
Programs used - AutoHotKey, EventGhost, XBMC, Hulu Desktop.
I've attached a photo so please reference that for the list below.
Starting with AutoStart, my HTPC opens EventGhost at startup, then EventGhost is what starts everything else for me.
AutoStart
Start Program: CPWizard.exe - CPWizard is a program I use to display MAME information when I play my arcade games.
Plugin: Directory Watcher - It's used to watch a folder when I download TV Shows. Article on this setup is here.
Plugin: Directory Watcher #2 - Disregard, it needs to be deleted as it currently has no function.
Plugin: XBMC - Plugin which gives me XBMC macros.
Plugin: Task Create/Switch Events - Keeps track of events from apps that you open and close and allows you to run macros after any event that you choose.
Continued Startup
After CPWizard - I was having issues with CPWizard. Initially I had CPWizard and XBMC in the Autostart above but CPWizard would load AFTER XBMC and for whatever reason, it would minimize XBMC. I would then have to grab my mouse and select XBMC from the Task Bar to open it/give it focus.
This is where the Plugin: Task Create/Switch Events comes into play. When CPWizard opens, it also minimizes and the event when it minimizes is Task.ClosedWindow.CPWizard so I told EventGhost that when it notices CPWizard minimize, to start XBMC. Doing so fixed the minimizing of XBMC.
The next two lines are for TED (Torrent Episode Downloader). TED is java based and JAVA kept crashing on my system when I started TED too early. What I did was created a 30 sec wait, after XBMC has loaded, to launch TED. It launches in the background and never messes with XBMC.
Launching Hulu
The problem with Hulu was it not focusing. You would select it from your list on XBMC, it would change to Hulu for a fraction of a sec and then it would come back to XBMC. This is what I did:
Focus Hulu
Launching Hulu - Using the Task Create/Switch Events plugin, I set the Task.Created.HuluDesktop event so that when EventGhost sees that event, it launches any macros after it and in this case, it's Quitting XBMC. The Quit XBMC macro can be found in the XBMC Plugin.
This didn't fix all my problems, only half. It quits XBMC but I still had issues with the focus. Even though it seemed Hulu Desktop was in the foreground, it wasn't, Windows was. I would need to click on Hulu Desktop before I would be able to control it with my remote. In order to fix it, the next macro needs to run.
Giving Focus to Hulu - The previous macro quits XBMC and one of the events created is Task.Destroyed.XBMC. When EventGhost sees that, it starts the program FocusHulu.exe. FocusHulu.exe is a compiled and modified version of the AHK script thesuffering (OP) had running in the background. Even though it worked, it had it's issues. The script was in a constant loop in the background and it didn't allow you to quit XBMC without it reopening it a second later.
Copy the following script into notepad and make sure it has the ahk extension.
Code:
{
IfWinExist, Hulu Desktop
{
WinActivate, Hulu Desktop
}
}
I tried running the ahk script through EventGhost but I kept getting errors. What I did instead was compile it with the compiler(Ahk2exe) found in Compiler folder of AutoHotKey. When you open ahk2exe, select the script and then from the File menu, select convert. Once finished, you'll have an executable! The beauty of this, if you haven't figured it out yet, is that it only runs when XBMC quits and if you decide quit XBMC, for any reason,, the script will run but since Hulu Desktop is not running, it won't have anything to activate, so it does nothing. It only focus on Hulu Desktop when you run Hulu Desktop. And now for the last part.
Launching XBMC after Quitting Hulu - When EventGhost notices you closing Hulu (Task.Destroyed.HuluDesktop), it runs the Start Program macro for XBMC. The rest, as they say is history!
Any questions let me know.