Jump to content
LaunchBox Community Forums

Platform Autohotkey Script


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
Link to comment
Share on other sites

  • 11 months later...
  • 10 months later...

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.

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...