Jump to content
LaunchBox Community Forums

Recommended Posts

This is for a per platform ahk script. I know we will get some additional app love at some point. In the mean time I made this simple plugin. It will start a compiled script on game starting event and will close it on game exited event.

 

How to use:

Drop the plugin into the plugins folder.

Create a new script within Launhbox/Autohotkey/ and compile it.

Name the script to exactly the same as you have the platform named in LB. (example: "Nintendo 64" in LB, "Nintendo 64.exe" in the Launchbox/autohotkey/ directory.

 

 

Iv included the source because if you can compile it, its simple enough to make it work with other apps.

Here's an example of loading xpadder:

Create a shortcut to xpadder, rename the shortcut to the same as the platform and place it inside, Launchchbox/autohotkey/ directory.

namespace PlatformAHK
{
    public class Class1 : ISystemEventsPlugin
    {
        private static string selectedGamePlatform;

        public void OnEventRaised(string eventType)
        {
            if (eventType == "GameStarting")
            {
                IGame selectedGame = PluginHelper.StateManager.GetAllSelectedGames()[0];
                selectedGamePlatform = selectedGame.Platform;

                string platformAHK = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AutoHotkey", selectedGamePlatform + ".lnk");

                if (File.Exists(platformAHK))
                {
                    Process process = new Process();
                    process.StartInfo.FileName = platformAHK;
                    process.Start();
                }
            }

            if (eventType == "GameExited")
            {
                Process[] Process = System.Diagnostics.Process.GetProcesses();
                for (int i = 0; i < Process.Length; i++)
                {
                    if (Process[i].ProcessName == "Xpadder")
                    {
                        Process[i].Kill();
                    }
                }
            }
        }
    }
}

You only need to change 2 lines:

string platformAHK = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AutoHotkey", selectedGamePlatform + ".lnk");

This line, change the .lnk at the end.

 

if (Process[i].ProcessName == "Xpadder")

Obviously change "Xpadder". Include the quotes. Don't add ".exe".

 

PlatFormAHK.zip

 

  • Like 1

Share this post


Link to post
Share on other sites

What do you change .lnk to? examples

This needs to made a feature, we need more additional app multi game editor.

Edited by NNEMO

Share this post


Link to post
Share on other sites

With changes that have been made during LaunchBox's evolution since 2 years ago, that whole line of the code ("string platformAHK.....") won't work anyway.  

You may want to look under Help & Support - Request a Feature and see if there's already a request for this feature and UpVote it.  If not, make a new request.

Share this post


Link to post
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
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...