apparently im stupid at autohotkey
#1
hi.
if somebody out there could please make me an autohotkey script that minimizes the xbmc window whenever i launch a game, and restores it when the game exits, i would appreciate it.

i have been pulling my hair out and grinding my teeth trying to figure out how to do this.

my last attempt was to replace launching the games themselves with launching a script for each game set to minimize xbmc, launch the game, and restore xbmc when the game has quit. unfortunately, dispite using WINWAITCLOSE in conjunction with WINRESTORE, i am unable to get this to work on the first game i tried (fable), even though for some reason THE EXACT SAME CODE (with changes only to the program path and the window title) works to minimize xbmc, launch firefox, and restore xbmc when i close firefox

i have no earthly clue why the f*k i cant get it to work with fable and im not even going to try the rest of my games until i understand (which i am sure i never will grasp what the hell the problem is)

so thanks in advance to anyone who can help me out here
Reply
#2
Have you looked at the Advanced Launcher add-on?
Reply
#3
yes, obviously Im already using a launcher, and it happens to be advanced launcher, yes.

are you suggesting that there is some option in advanced launcher which will automatically minimize and restore XBMC for me whenever a game is launched/closed?
cuz if thats the case, I cant seem to find that option, and am instead forced to try and figure a way to accomplish this with autohotkey
Reply
#4
(2012-10-06, 17:56)opinionatedrone Wrote: yes, obviously Im already using a launcher, and it happens to be advanced launcher, yes.

are you suggesting that there is some option in advanced launcher which will automatically minimize and restore XBMC for me whenever a game is launched/closed?
cuz if thats the case, I cant seem to find that option, and am instead forced to try and figure a way to accomplish this with autohotkey
Concerning Advanced Launcher :


(2012-08-31, 23:36)opinionatedrone Wrote: my last attempt was to replace launching the games themselves with launching a script for each game set to minimize xbmc, launch the game, and restore xbmc when the game has quit. unfortunately, dispite using WINWAITCLOSE in conjunction with WINRESTORE, i am unable to get this to work on the first game i tried (fable), even though for some reason THE EXACT SAME CODE (with changes only to the program path and the window title) works to minimize xbmc, launch firefox, and restore xbmc when i close firefox

i have no earthly clue why the f*k i cant get it to work with fable and im not even going to try the rest of my games until i understand (which i am sure i never will grasp what the hell the problem is)
Simply because, under Windows, Firefox and Fable executables do not start and close with the same way. They do not use the same graphical ressources and the same way to proceed to start, maximize, focus, minimize, etc... So it is pratically impossible to write a script that will work perfectly with all the existing applications.

Reply
#5
I am using Advanced Launcher 1.7.9
I have XBMC set to use a fullscreen window rather than true fullscreen
I have not messed with the Toggle XBMC Fullscreen option, it is set to the default value (true)
I have never used bash scripts or AutoIt, looking into that now.

I apologize for the crude nature of my original post, I was extremely frustrated with this issue when I posted it.

I have since tried similar code to launch games such as SKYRIM and GTA: San Andreas. When I used my script to launch SKYRIM I was unable to load any of my savegame files, the game reported that they were corrupt and offered to delete them. I declined, as I know for a fact that they are not corrupt (I closed Skyrim, reopened it via the Skyrim Launcher, everything worked fine)
I believe part of the problem here is that I was not specifying a working directory for Skyrim.

I understand that a browser program and a video game program (firefox/fable) are going to have different methods of launching and exiting, as well as use many different resources. I am new to AutoHotKey, but surely there must be a way to detect when any program has quit/closed and thus prompt a scripted action. I know, for example, that it is possible to hook on to Windows DLL calls for use with AutoHotKey, but I'm not well versed enough to code up a script to accomplish my goals.

Thank you for your assistance in this matter. If you could include an option to minimize XBMC whenever something is launched from Advanced Launcher (as in Advanced Launcher 0.9.5 http://forum.xbmc.org/showthread.php?tid=85724&page=99 ) in the next version, my problems would be solved.
Reply
#6
(2012-10-07, 20:26)opinionatedrone Wrote: Thank you for your assistance in this matter. If you could include an option to minimize XBMC whenever something is launched from Advanced Launcher (as in Advanced Launcher 0.9.5 http://forum.xbmc.org/showthread.php?tid=85724&page=99 ) in the next version, my problems would be solved.
As it is mentioned it is include since version 0.9.5 of Advanced Launcher and the option is named Toggle XBMC Fullscreen and it is activated by default. It was working perfectly with Dharma versions of XBMC, but not even so perfectly with Eden versions of XBMC.

(2012-10-07, 20:26)opinionatedrone Wrote: I am using Advanced Launcher 1.7.9
Please use an updated version of Advanced Launcher, Since version 1.7.9, version 1.7.14 has bring some xbmc windows focus fixes that will surely fix a part of your problem..

(2012-10-07, 20:26)opinionatedrone Wrote: I have since tried similar code to launch games such as SKYRIM and GTA: San Andreas. When I used my script to launch SKYRIM I was unable to load any of my savegame files, the game reported that they were corrupt and offered to delete them. I declined, as I know for a fact that they are not corrupt (I closed Skyrim, reopened it via the Skyrim Launcher, everything worked fine)
I believe part of the problem here is that I was not specifying a working directory for Skyrim.

I understand that a browser program and a video game program (firefox/fable) are going to have different methods of launching and exiting, as well as use many different resources. I am new to AutoHotKey, but surely there must be a way to detect when any program has quit/closed and thus prompt a scripted action. I know, for example, that it is possible to hook on to Windows DLL calls for use with AutoHotKey, but I'm not well versed enough to code up a script to accomplish my goals.
I have never used AutoHotKey. I prefer to use Autoit, wich is more simple and more powerfull. So, here is how I start Skyrim form XBMC on my Windows 7 system using a Autoit script. First, install Autoit and you system. You will need it to compile your autoitscript (.au3) into executable files (.exe). Then create this TESV-launcher.au3 script and save it into the The Elder Scrolls V Skyrim directory :

Code:
Run ( 'C:\Program Files (x86)\The Elder Scrolls V Skyrim\TESV.exe','C:\Program Files (x86)\The Elder Scrolls V Skyrim\')
ProcessWaitClose ( "TESV.exe" )
WinSetState("XBMC", "", @SW_MAXIMIZE)

The script start Skyrim application (C:\Program Files (x86)\The Elder Scrolls V Skyrim\TESV.exe) and define C:\Program Files (x86)\The Elder Scrolls V Skyrim\ as working directory. Then the script wait until the TESV.exe application will be closed. When it will be done, the script will maximize XBMC. That's all.

To make all this work, compile the TESV-launcher.au3 file into TESV-launcher.exe. Then into Advanced Launcher create a stand alone launcher with C:\Program Files (x86)\The Elder Scrolls V Skyrim\TESV-launcher.exe as application and without any argument.
Reply
#7
I'm writing little power-shell scripts which are working perfectly fine for me (for the most time, at other occasions I use AutoIT for reasons explained a little bit further down).

I just the call "Start-Process "Path\To\Exe\Filename.exe" -Wait" - this works fine and the launched powershell will stay open until the launched process is being closed. As long as the powershell-script is open, XBMC stays minimized.
This works fine for most games, except the ones that absolutely require a launcher to be started (FIFA 12/13, Borderlands2, etc., etc.), because in that scenario the powershell closes as soon as you can see the launcher (probably not if I'd call the launcher-binary directly, but well - if you call the game binary, the process will be closed as soon as the launcher has been launched).
Works fine for me, and I even wrote a little application which does the writing of the launcher-scripts (not that it would be necessary Wink ).
Need help? Check out my XBMC Frodo Guide. It contains full featured guides to Sickbeard and CouchPotato as well.

Image
Reply
#8
The following is what I use to launch one specific game/ program after killing XBMC - and then relaunching XBMC after killing the game.

I use NirCmds - free download (32 bit here, 64 bit here), in combination with AutoHotkey.

To kill XBMC, and launch your game:

Batch file to launch any game - just create a shortcut to the exe, and put the following in the batch file.

Below - C:\Users\buddy\Desktop\Harmony One buttons Bat file for RecentAdded and Playlists is where I installed nircmd.

Killprocess - kills the process xbmc. WaitProcess is another good one.

Dream_Aquarium.scr - what I was launching - but would be your game that you want launched.

Code:
"C:\Users\buddy\Desktop\Harmony One buttons Bat file for RecentAdded and Playlists\nircmd\nircmd.exe" killprocess "XBMC.exe"

"C:\Users\buddy\Desktop\Dream_Aquarium.scr - Shortcut.lnk"

To kill your game and launch XBMC:

Autohotkey script - put a shortcut to it in your startup folder. When your xbmc system receives the Win+alt+enter keyboard shortcut, it will launch XBMC if it's not running - otherwise if running, it will maximize XBMC.

Code:
;Win-Alt-Enter is the shortcut for GreenButton
#!Enter::
    IfWinNotExist XBMC.exe ;If XBMC is shutdown
        Run C:\Program Files (x86)\XBMC\XBMC.exe ;Start it
        WinWait,XBMC,,5 ;wait for 5 seconds for it
        If ErrorLevel ;Display an error in case it times out.
        {
            MsgBox, XBMC Startup timed out.
            return
        }
    WinActivate ;Activate the window, in case the it's in the background.
    WinMaximize ;Maximize the window.
    WinShow ;Bring it to front.
    return

        SetTitleMatchMode 2 ;Search string
        #IfWinActive XBMC ahk_class XBMC ; Detect when XBMC is active
        #!Enter::send, ^!{F5} ; if Active (GSB Home Jump will activate)
        Return
        #IfWinActive ;

Then, I create a batch file to be run that does the following - closes the foreground window (whatever your game is), and then sends the keypress combination of Win + alt + enter to launch XBMC.

Code:
"C:\Users\buddy\Desktop\Harmony One buttons Bat file for RecentAdded and Playlists\nircmd\nircmd.exe"  win close foreground

"C:\Users\buddy\Desktop\Harmony One buttons Bat file for RecentAdded and Playlists\nircmd\nircmd.exe" sendkeypress lwin+alt+enter

Final tip - when you create your batch files, create shortcuts to them, and after right-clicking on the shortcut and choosing properties, run them minimized, and with administrative priviledges (on Advanced tab).
Image
Image
Image
Reply

Logout Mark Read Team Forum Stats Members Help
apparently im stupid at autohotkey0