This focus stealing problem in Window 7 is really annoying and it seams it can not be disabled in OS like in Windows XP. Well done MS!
In order to overcome this problem I picked up baijuxaviors Autoscript cause the Focusbitch idea has some flaws for me:
One point is in the first 30 seconds it is impossible to start external programs cause Focusbitch won't let you. After that period my VPN connection still bothers me when breaking down. And a neverending Focusbitch is no solution cause it makes external programs like games impossible. But I like to start them inside XBMC so I extended the script to fit my needs. Perhaps it is usefull for some other folks out there. It works with a windowed OR a fullscreen XBMC!! Fullscreeen should be preferred.
The idea is to start XBMC with an compiled Autoscript executable and maintain its focus all the time - so no visible desktop anymore.
But when an external program like a game is started the script has to stop giving XBMC the focus and should keep on working after the game ended. To do so I choose an old DOS method called flag files. So when a defined file (xbmc_external) do exit in a certain path the script will stop giving XBMC the focus. After this flag file is deleted it goes back to XBMC automatically.
So everything we need besides the Autoscript program is a start batch file that creates the flag file when starting the game and deletes it after work is done. I use XMBC advanced launcher to start this batch file that is given the external program I want to start as a parameter.
So first of all download AutoHotkey and install it on your computer:
Homepage AutoHotkey
Then cut&paste this script file and save it as XBMC.ahk:
---------------------- ziiiippp ----------------------
#NoEnv
#SingleInstance ignore
SendMode Input
SetWorkingDir %A_ScriptDir%
; #!Enter:: ; Add a hotkey to start xbmc using Ctrl+Alt+Enter. Useful for the mce green button.
; Path and Flag Files
XBMCPath = c:\Program Files (x86)\XBMC
ScriptPath = C:\Script
Flag = xbmc_external
run %XBMCPath%\XBMC.exe
loop
{
Process, Exist, xbmc.exe
If (ErrorLevel = 0)
{
return
}
WinActivate, ahk_class XBMC
WinWaitActive, ahk_class XBMC
sleep 400
loop
{
IfExist, %ScriptPath%\%Flag%
{
sleep 1000
Process, Exist, xbmc.exe
If (ErrorLevel = 0)
{
return
}
}
else
{
break
}
}
}
return
---------------------- ziiiippp ----------------------
Check the path information in the header to fit your needs and save it to your harddisk. Right click this saved file and you should see the "compile script" in the menu. This generates an executable for you that will start XMBC and maintain its focus. Put it in your autostart folder and see if it works. When exiting XBMC this script will terminate, too. So use the compiled script to start your XBMC all the time.
Default Path for XBMC installation here is c:\Program Files (x86)\XBMC\
And default path for the batch file and flag folder is: C:\Script\
Now we need a proper batch file for starting our external programs:
---------------------- ziiiippp ----------------------
@
echo off
set ScriptPath=C:\script
cd %ScriptPath%
echo . > xbmc_external
cd "%~p1"
call "%~n1"
cd %ScriptPath%
del xbmc_external
---------------------- ziiiippp ----------------------
Modify the second line to your needs and save it as START_EXTERNAL.BAT in your script folder (e.g. C:\Script\)
This batch will care for the flag file and call your external program. It will wait until it terminates and delete the flag file so XBMC will show up again.
Now we are able to configure our first external program in advanced lancher!
Since a batch file needs a command shell to work the program to start in advanced lancher is not the batch itself but the windows command shell executable. You find this one in your Windows / System32 folder. (eg. c:.\windows\system32\cmd.exe)
Select this shell as the program to execute in advanced lancher and after this we start editing the important start parameters.
In case your Script directory is C:\script\ use the following parameter to start your game.exe in the c:\games_folder\ path (example):
/c c:\script\start_external.bat "c:\games_folder\game.exe"
You see the first parameter is "/c" and tells cmd.exe to carry out the command specified by the following string and then terminate.
The second parameter is the saved start batch file and the third parameter is your extermal program with its full path.
Try and have fun!
Mike