2009-08-03, 03:51
Hey guys, new to the forums, been using XBMC for a little bit. Hope this is the right place to post this, I don't know if it really counts as a 'mod' or more of a hack. Anyways, I'd been looking for something that could launch an external program from XBMC for a while, and while the program launcher is available it wasn't quite what I wanted, I just wanted to be able to launch 1 specific program from the main menu.
This is a simple mod, you only have to script 1 python script and edit 1 xml file.
In my example below I'm using a python script to launch a program (which in turn launches several other programs and returns when they close)
As you can see all that's really necessary is the python launcher and the main menu to call the python.
----------
Ok here's a quick writeup on how to mod your XBMC to launch HyperSpin directly from the Home menu. This WILL disable your 'my programs' submenu entirely. Though I'm sure you could mod it differently I wanted this to replace the 'My Programs / My Games' on the Aeon Stark skin because all the other settings menus remain in tact, meaning you can still setup backdrops without making any additional mods.
This mod consists of 4 basic things
1) Home Menu edit
2) Python script
3) AHK Hyperspin launcher
4) AHK XBMC launcher
First I will explain a little bit about why I scripted things the way I did.
The primary reason was to minimize cpu/memory use.
The second was that I have read that Hyperspin / XBMC don't like to play nice together and that there can be some issues when trying to run both programs simultaneously.
The final reason is to make it easily customizable for each users needs - if you want to launch / close extra programs, you can.
The following is a basic flowchart of how this wrapper works:
--------------------
PART 1: Python Script (launcher.py)
The Following is assuming that you have XBMC installed in it's default location of
C:\Program Files\XBMC\
From here out referred to as 'XBMC root'
Copy the above code to notepad and save it in the XBMC root as launcher.py If necessary edit the path to your XBMC root.
---------------
PART 2: HyperSpin AHK Script (spinner.ahk)
This script also goes in the XBMC root directory.
At the very beginning of the script you will see an area to set paths to your programs. adjust them accordingly.
The numbers in green are the timeouts that the script will run while waiting for the respective program to 1)launch 2)gain focus. You can lengthen / shorten these according to your system specs. The defaults seem to work well.
If the script cannot find HyperSpin.exe it will relaunch XBMC.exe and exit the script. IF it cannot find XBMC.exe to relaunch - it will throw an error asking if your paths are correct. Check, and recompile.
compile this script as spinner.exe (which the python script was looking for)
* If you want to run another program I would add the 'run' command right before the final 'sleep, 3000' and before the 'gui, destroy' lines.
---------------
PART 3: XBMC Launcher AHK Script (Xlauncher.ahk)
This script also goes in the root xbmc directory
again, edit your path to XBMC - if it isn't the default - and adjust the timeouts in green if necessary.
If you have any programs you want to close (Xpadder, Ledblinky...)
use 'process, close,' right before the 'run, %xbmc%' line.
Compile and save as Xlauncher.exe
Open HyperHQ and set this program as the program you want to run on exit.
*it technically isn't necessary for this to be in the XBMC root - just makes it easier to find.
----------
PART 4: SKINS
++++++++++
AEON STARK
find the following file
'Includes_mainmenu.xml'
by default it will be under
\skin\Aeon\720p\
from your XBMC root directory.
Open it in your favourite text editor and find the following:
replace it with the following:
Make sure the path to your python script (launcher.py) is correct. Save and exit.
++++++++++
Media Stream
Find the file 'home.xml'
by default under
\skin\MediaStream\720p\
from the XBMC root
open it and find the following:
and replace it with:
Check that the path to the python script (launcher.py) is correct and save.
----------
well that's it - I know it's a long post, but it's mostly just checking that paths are correct.
NOTES:
The wrapper will work best if your desktop / XBMC / Hyperspin all are set to the same resolution.
KNOWN ISSUES:
The script will disable the 'programs/Games' feature of AEOn, however as many of you already know it is possible to add another main menu item. I was just lazy in implementation.
Please leave feedback / comments / requests below.
----------
As you can see the only vital parts are 1 and 4.
This is a simple mod, you only have to script 1 python script and edit 1 xml file.
In my example below I'm using a python script to launch a program (which in turn launches several other programs and returns when they close)
As you can see all that's really necessary is the python launcher and the main menu to call the python.
----------
Ok here's a quick writeup on how to mod your XBMC to launch HyperSpin directly from the Home menu. This WILL disable your 'my programs' submenu entirely. Though I'm sure you could mod it differently I wanted this to replace the 'My Programs / My Games' on the Aeon Stark skin because all the other settings menus remain in tact, meaning you can still setup backdrops without making any additional mods.
This mod consists of 4 basic things
1) Home Menu edit
2) Python script
3) AHK Hyperspin launcher
4) AHK XBMC launcher
First I will explain a little bit about why I scripted things the way I did.
The primary reason was to minimize cpu/memory use.
The second was that I have read that Hyperspin / XBMC don't like to play nice together and that there can be some issues when trying to run both programs simultaneously.
The final reason is to make it easily customizable for each users needs - if you want to launch / close extra programs, you can.
The following is a basic flowchart of how this wrapper works:
Quote:Run XBMC
- Click 'HyperSpin'
- Run Python Script
- Run Hyperspin Launcher
- Close Python Script
- Close XBMC
- Run HyperSpin
- Run other programs if desired
- Close HyperSpin Launcher
- Exit HyperSpin
- Run XBMC Launcher
- Close other programs if opened previously
- Run XBMC
- Exit XBMC Launcher
- Exit XBMC
--------------------
PART 1: Python Script (launcher.py)
The Following is assuming that you have XBMC installed in it's default location of
C:\Program Files\XBMC\
From here out referred to as 'XBMC root'
Quote:import os, subprocess
subprocess.Popen(["c:\Program Files\XBMC\spinner.exe"], shell=False)
Copy the above code to notepad and save it in the XBMC root as launcher.py If necessary edit the path to your XBMC root.
---------------
PART 2: HyperSpin AHK Script (spinner.ahk)
This script also goes in the XBMC root directory.
Quote:#SingleInstance force
;----------SET PATHS----------;
XBMC = "C:\Program Files\XBMC\XBMC.exe"
HyperSpin= "E:\HyperSpin\HyperSpin.exe"
;-----------------------------;
blockinput, on
SetTitleMatchMode, 2
Gui, Color, 000000
Gui, -Caption +ToolWindow +AlwaysOnTop
Gui, Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight%,
process, close, xbmc.exe
run, %HyperSpin%,, UseErrorLevel
if ErrorLevel
{
run, %XBMC% -fs -p,, UseErrorLevel
if Errorlevel = ERROR
{
gui, destroy
blockinput, off
msgbox, 0, ERROR, neither %XBMC% or %HyperSpin% was found - Make sure you have correct paths, 4
ExitApp
}
WinWait, XBMC, , 5
IfWinNotActive, XBMC, , WinActivate, XBMC,
WinWaitActive, XBMC, , 5
if ErrorLevel
{
gui, destroy
blockinput, off
ExitApp
}
sleep, 5000
gui, destroy
blockinput, off
ExitApp
}
WinWait, HyperSpin, , 3
IfWinNotActive, HyperSpin, , WinActivate, HyperSpin,
WinWaitActive, HyperSpin
sleep, 3000
gui, destroy
blockinput, off
ExitAPP
At the very beginning of the script you will see an area to set paths to your programs. adjust them accordingly.
The numbers in green are the timeouts that the script will run while waiting for the respective program to 1)launch 2)gain focus. You can lengthen / shorten these according to your system specs. The defaults seem to work well.
If the script cannot find HyperSpin.exe it will relaunch XBMC.exe and exit the script. IF it cannot find XBMC.exe to relaunch - it will throw an error asking if your paths are correct. Check, and recompile.
compile this script as spinner.exe (which the python script was looking for)
* If you want to run another program I would add the 'run' command right before the final 'sleep, 3000' and before the 'gui, destroy' lines.
---------------
PART 3: XBMC Launcher AHK Script (Xlauncher.ahk)
This script also goes in the root xbmc directory
Quote:#SingleInstance force
;----------SET PATHS----------;
XBMC = "C:\Program Files\XBMC\XBMC.exe"
;-----------------------------;
blockinput, on
SetTitleMatchMode, 2
Gui, Color, 000000
Gui, -Caption +ToolWindow +AlwaysOnTop
Gui, Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight%,
run, %XBMC% -fs -p,, UseErrorLevel
if ErrorLevel
{
gui, destroy
blockinput, off
msgbox, 0, ERROR, %XBMC% was not found - Make sure you have correct paths, 4
ExitApp
}
WinWait, XBMC, , 5
IfWinNotActive, XBMC, , WinActivate, XBMC,
WinWaitActive, XBMC, , 5
if ErrorLevel
{
sleep, 5000
gui, destroy
blockinput, off
ExitApp
}
sleep, 5000
gui, destroy
blockinput, off
ExitAPP
again, edit your path to XBMC - if it isn't the default - and adjust the timeouts in green if necessary.
If you have any programs you want to close (Xpadder, Ledblinky...)
use 'process, close,' right before the 'run, %xbmc%' line.
Compile and save as Xlauncher.exe
Open HyperHQ and set this program as the program you want to run on exit.
*it technically isn't necessary for this to be in the XBMC root - just makes it easier to find.
----------
PART 4: SKINS
++++++++++
AEON STARK
find the following file
'Includes_mainmenu.xml'
by default it will be under
\skin\Aeon\720p\
from your XBMC root directory.
Open it in your favourite text editor and find the following:
Quote: <item id="2">
<label>31011</label>
<onclick>XBMC.ActivateWindow(MyPrograms)</onclick>
<visible>!Skin.HasSetting(noprograms)</visible>
</item>
replace it with the following:
Quote: <item id="2">
<label>HyperSpin</label>
<onclick>XBMC.RunScript(C:\program files\XBMC\launcher.py)</onclick>
<visible>!Skin.HasSetting(nogames)</visible>
</item>
Make sure the path to your python script (launcher.py) is correct. Save and exit.
++++++++++
Media Stream
Find the file 'home.xml'
by default under
\skin\MediaStream\720p\
from the XBMC root
open it and find the following:
Quote: <item id="4">
<description>My Programs Menu</description>
<label> $LOCALIZE[31004] </label>
<label2> $LOCALIZE[31014] </label2>
<visible>!Skin.HasSetting(HidePrograms)</visible>
<onclick>XBMC.ActivateWindow(1)</onclick>
</item>
and replace it with:
Quote: <item id="4">
<description>My Programs Menu</description>
<label>HyperSpin</label>
<label2>Launch</label2>
<visible>!Skin.HasSetting(HidePrograms)</visible>
<onclick>XBMC.RunScript(C:\program files\XBMC\launcher.py)</onclick>
</item>
Check that the path to the python script (launcher.py) is correct and save.
----------
well that's it - I know it's a long post, but it's mostly just checking that paths are correct.
NOTES:
The wrapper will work best if your desktop / XBMC / Hyperspin all are set to the same resolution.
KNOWN ISSUES:
The script will disable the 'programs/Games' feature of AEOn, however as many of you already know it is possible to add another main menu item. I was just lazy in implementation.
Please leave feedback / comments / requests below.
----------
As you can see the only vital parts are 1 and 4.