Jump to content
LaunchBox Community Forums

AHK not executing for Windows games


blahblablee

Recommended Posts

I'm on ver 11.6, windows 10

I am attempting to use the AHK Script before launching Windows game(via the tools menu options) to run a program to map keyboard inputs to x-input before launching windows games. Whenever I launch Windows games in both Launchbox or Big Box it doesn't seem like the AHK gets executed at all. I've attempted to execute the AHK script on its own with AHK and it works outside of Launchbox/Big Box with no issues.

Link to comment
Share on other sites

1 hour ago, JoeViking245 said:

When you do it this way, then launch a [Windows] game from LB/BB, does it work as expected in the game?

Yep this basically works except that the last line of the script does nothing, so where I would expect whatever game application to close it remains open(though I've stolen that from other AHK scripts I've seen on the forum and my understanding is that's a LB/BB specific thing that can close applications executed by LB/BB). It really appears as though it is just not getting executed at all by LB/BB on Windows game launch.

Link to comment
Share on other sites

Windows games really should be exited using their "Exit to Windows" menu item.   "Process, Close" is like turning off the power strip to the PC in mid game.  A little "nicer" way would be to use 

WinClose, ahk_exe {{{StartupEXE}}}

If you are bound and determined to use a hotkey to exit the game, your best method would be

$Esc::
{
   WinClose, ahk_exe name_of_the_Windows_game.exe
}

This makes sure you're closing the right window, whereas the other way may inadvertently close something else.  In the case of your script, it's probably trying to close "XArcade XInput.exe".  The executable the script initially started.

Of course the problem with this is it's not generic.  You'd need to create a game specific Additional App for each game. 

With your script as it sits, [not starting it on its own first] and launching your Windows game from LB/BB, does "XArcade XInput.exe" get closed when you hit Escape during game play?  [then of course going through game's menu to Exit To Windows to get back to LB/BB]

Edited by JoeViking245
Link to comment
Share on other sites

Good to know regarding killing the running game. Yeah I'm not really opposed to games getting terminated non-gracefully in most cases and it's not like that excludes the option to use the game menus anyway. I get it though it's like hitting alt f4 or some other forced exit, in terms of small potential to cause some issues on occasion.

 

And no if I only use LB/BB to run the game, the AHK script never seems to start, so the xinput application doesn't start at all nor does the escape binding do anything.

Again if I run it on the side and launch something through LB/BB the script works as expected with the exception of exiting the game application, it starts the xinput application and the escape key does close the xinput application.

Link to comment
Share on other sites

Thanks for the suggestion but it doesn't appear to improve the situation. With the quotes my AHK actually errors on syntax if I run it outside of LB/BB and it still doesn't get run by the execution inside of LB/BB.

I also tried cleaning up the syntax by removing the quotes, such that it would run outside of LB/BB properly (basically just your Esc binding changes) and still no execution from LB/BB.

 

At this point I'm assuming there's either some type of bug with the execution or there's some type of permission issues with my LB/BB files or executables such that it can't run the AHK script on game execution.

Link to comment
Share on other sites

Let's see your final script.   I ran a test here and it seemed to work.  Granted I don't have XArcade....exe nor a Windows game, but it did work using two other exe's.  LB started the exe in the script, then stated the "game'.  Then when pressing Escape, the exe closed and then the 'game'.

Your XArcade should at least be able to start up.  But the Windows game [being a Windows game] might not be so inclined to cooperate [when forcing a close in this manner]. 

Link to comment
Share on other sites

Add this in the script somewhere (like maybe the line above "Run" and after the 1st bracket - before the 1st WinClose.

SoundBeep,1000,100

Run a Windows game and see if you hear a beep(s) at all (while its loading and again when you hit Escape).

if No

Is your LaunchBox, BigBox or AutoHotkey.exe set to run as Admin?  If so, don't do that.  It's neither advised nor supported. (I mean, I suppose you could. But It'll really screw things up.)   Sounds like you might have your own install in AHK [C:\Program Files\AutoHotkey\] which is NOT a problem.  But check that as well as the one in ../LaunchBox/ThirdParty/AutoHotkey/   

Is the game you're testing for-sure in your "Windows" Platform? (have to ask)

if Yes [beep]: 

This is a good thing. :)  Well... a step in the process of elimination.

Link to comment
Share on other sites

Ok so firstly nothing is set to run as admin, not the LB/BB or third party folder exe for AHK. Yeah I do have another installation of AHK I had installed for troubleshooting purposes.

So after I added the soundbeeps in those 2 places and got nothing. Went and double checked the game I've been debugging with (I've been using the same one for sanity sake) and it is set to Windows Platform.

Link to comment
Share on other sites

Well Snap!  Time for Plan "B".  (or is it "C" now?  "D"?)

Copy your above script (go ahead and keep the beeps in).  Create a new text document and paste the script into it.   Save the file somewhere [that isn't your Desktop, C:\ root drive, C:\Programs Files or anywhere like that].  Inside your root LaunchBox folder is fine for now.  Save it (or rename it after saved) to have an ahk extension.

i.e.  C:\LaunchBox\winTest.ahk  

Since [full] AHK is installed, you should be able to right click the file [in Windows Explorer] and select "Compile Script".  This will give you   C:\LaunchBox\winTest.exe

In LaunchBox, Edit your Windows ['one for sanity sake'] game.  Click Additional Apps, then Add Application....   Give it an Application Name:.  Click Browse... then navigate to your "C:\LaunchBox\winTest.exe" file and click Open.  Check the box for Automatically Run Before Mail Application.  Click OK.  OK.image.thumb.png.5640f0fb6d0e214073596d24a3b493c5.png

Since the script doesn't work at all in when in the 'AHK Scripts For Windows', you shouldn't need to remove that.  But it wouldn't hurt to delete that anyway.

Run/launch/Play the game. 

Link to comment
Share on other sites

Well that does work for whichever games I load that configuration in to. Kind of a pain to do so for all Windows games. Honestly even more puzzling why I'm having an issue with the other 'AHK Scripts for Windows'. Just for the hell of it I tried temporarily replacing the AHK exe in third party with the other I had installed and still no dice for the 'AHK Scripts for Windows'. I'm considering trying to delete my 'Windows' platform and recreate it/re import games to see if there is in fact something wrong with how my platform got configured or something.

Link to comment
Share on other sites

28 minutes ago, blahblablee said:

Well that does work for whichever games I load that configuration in to. Kind of a pain to do so for all Windows games. Honestly even more puzzling why I'm having an issue with the other 'AHK Scripts for Windows'. Just for the hell of it I tried temporarily replacing the AHK exe in third party with the other I had installed and still no dice for the 'AHK Scripts for Windows'. I'm considering trying to delete my 'Windows' platform and recreate it/re import games to see if there is in fact something wrong with how my platform got configured or something.

All the games in your Windows platform did you install them using the >Tools>Import>Import Windows Games option or are these just pc games you added the .exe or shortcut link manually?

I have never used that Edit AHK Script for Windows Games option, but I am thinking maybe that option is only for games imported using the Import Windows Games since LB detects them as such. I could be wrong, but I doubt it has anything to do with the platform name of "Windows" since you can call the platform name anything you want and still have Windows games in it. I will check with Jason.

Link to comment
Share on other sites

33 minutes ago, Retro808 said:

All the games in your Windows platform did you install them using the >Tools>Import>Import Windows Games option or are these just pc games you added the .exe or shortcut link manually?

I have never used that Edit AHK Script for Windows Games option, but I am thinking maybe that option is only for games imported using the Import Windows Games since LB detects them as such. I could be wrong, but I doubt it has anything to do with the platform name of "Windows" since you can call the platform name anything you want and still have Windows games in it. I will check with Jason.

These were imported with the 'Steam' and 'Epic Games' not 'Windows' games I imagine this is the issue I'm having then. A little bit intuitive if that is the issue as these are technically 'windows' games. Would changing the metadata of like the Status or Source fields get the result I was hoping for?

Link to comment
Share on other sites

49 minutes ago, blahblablee said:

These were imported with the 'Steam' and 'Epic Games' not 'Windows' games I imagine this is the issue I'm having then. A little bit intuitive if that is the issue as these are technically 'windows' games. Would changing the metadata of like the Status or Source fields get the result I was hoping for?

EDITED:

I did just confirm that the option you are trying to use does not call the AHK script when it is Windows games imported via the third party launcher options (Steam, GOG, etc.).

Link to comment
Share on other sites

 

5 minutes ago, Retro808 said:

does not call the AHK script when it is Windows games imported via the third party launcher options (Steam, GOG, etc.).

Does this then "Tag" the game that's in the Windows Platform somewhere/somehow? 

 

My test was done by drag-and-drop and choosing None of the Above.  I 1st created a new Platform and typed in [named it] Windows.  Did the drag-and-drop, None of the Above, selected the Windows Platform, No Metadata/Images.  My "game" was Notepad++.   Done that way, the 'Edit AutoHotkey Script for Windows Games' did work for me.  image.thumb.png.7e350cf4fb10759c3f7b2b11f993ee9a.pngimage.png.b5bfd1f264545a9637e91ec24824bce5.pngMy test script

run C:\Program Files\MediaInfo\MediaInfo.exe

$Esc::
{
   WinClose, ahk_exe MediaInfo.exe
   WinClose, ahk_exe {{{StartupEXE}}}
}

  

1 hour ago, blahblablee said:

I'm considering trying to delete my 'Windows' platform and recreate it/re import games to see if there is in fact something wrong with how my platform got configured or something.

I think that would be the next logical thing to try.  This (Additional App) does at least confirm that AHK is indeed working from inside LB on your setup.

I do have a Plan "E" that wouldn't involve having to edit each and every Windows game.  But we shouldn't have to do that. Especially since we now know that AHK will work.  (Confirmed with the Additional App)

Link to comment
Share on other sites

8 minutes ago, JoeViking245 said:

 

Does this then "Tag" the game that's in the Windows Platform somewhere/somehow? 

 

My test was done by drag-and-drop and choosing None of the Above.  I 1st created a new Platform and typed in [named it] Windows.  Did the drag-and-drop, None of the Above, selected the Windows Platform, No Metadata/Images.  My "game" was Notepad++.   Done that way, the 'Edit AutoHotkey Script for Windows Games' did work for me. 

If I understand what I was told this option will get called before running any raw executable for any game that does not have say a GOG id or Steam ID assigned to it. So if it as imported using one of the 3rd party launcher import features the Windows AHK tool will not be called.

So using the drag and drop would work as you tested.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...