Jump to content
LaunchBox Community Forums

Can LB pass variables to AutoHotkey?


Recommended Posts

  • 2 years later...

If you set your script to be the executable for an emulator, it will pass the rom name as %1%.image.png.f421740912fbf8244ee6d4bd233330bc.pngThis is one I made that will show a splash screen of the game specific controls (.png file), then launch the game.  Say I have this setup as my Arcade platforms' emulator and I go to start Donkey Kong.  LaunchBox will pass to the AHK script  dkong  as %1%.

Note that, if both check boxes were unchecked, %1% would be   "D:\LaunchBox\Games\Arcade\dkong.zip"

Also, I'm not sure, but possibly depending how it's used in the script, it may be %1  vs   %1%.  Don't know off hand.  Confirmed. It's %1%

Now, if you were to put your script (text) under the "Running AutoHotKey Script" tab...,image.thumb.png.46f5df54f69527fb7bd44c5583aba85b.png...LaunchBox will NOT pass anything to %1%. 

Well, in fact, it's only to the Emulator Application the %1% will be passed.  So it won't be passed to a script you use in the Additional Apps for a game either.

I think there was something passed as %2% also but have no recollection what it was.  Then again, could be thinking of something completely different. ? Confirmed. I was thinking about something completely different.

So I still contend, LaunchBox can be utilized to start ANY program.  You just may have to concoct a pseudo program (i.e. AHK script) to act as a middle man in obscure cases.

 

Edited by JoeViking245
  • Like 2
Link to comment
Share on other sites

Isn't the way the exit screen works is when bb regains focus it triggers the exit screen or something like that. So if loading a script there isn't a window to take the focus? 

 

Maybe try build a gui into ur script and keep it open behind the emulator and close it when emulator exits. Not sure how well it will work. Might get some nasty flicker. Maybe try and build a loading and exit screen into the script instead of using bb screens. 

 

Or Maybe the exit screen works on process so have the script continuously run in the background until emulator exits. 

Edited by jayjay
Link to comment
Share on other sites

4 hours ago, jayjay said:

when bb regains focus it triggers the exit screen

That makes total sense.  LB launches the script then it's the script that launches the emulator/game. After that, this script is done.  LB sees that and thinks, they're done playing, show the exit screen and return.  Which you don't see because your playing a game.

So, along those lines and just totally guessing here.... in the 'Emulator' script, launch the emulator with RunWait.

RunWait, %MAME% "%RomDir%\%1%", , Hide
Exitapp

 

Link to comment
Share on other sites

  • 8 months later...

Funny, I was just messing with this the other day. :)   Some things I learned about doing this...

The variable passed can be retrieved in the script in 2 different ways.  "param in A_Args[1]"  or  %1%.  (The latter being a little more direct approach.)  Changing "1" to whichever argument you wish to retrieve.  

%0% will give you the total number of arguments that are available.  This is important especially when using %platform% because if a platform has more than 1 word in it, it will be broken out into separate arguments.  Example: Nintendo Entertainment System

Using the custom command line    %romfile% %platform%   will give the following arguments results

%0%  =  4
%1%  =  the_name_of_the_game.zip
%2%  =  Nintendo
%3%  =  Entertainment
%4%  =  System

To get the full platform name in your script, use

Loop %0%                  ;total # of available arguments
{
   if (A_Index < 2)       ;2 is the # of parameters you passed. Adjust accordingly
       Continue		
   if (A_Index <= %0%)
       n .= %A_Index% " "
}
;  %n% = the [full] Platform Name

For this to work, you MUST include the %romfile% parameter AND have the %platform% parameter as the last one.  If you don't include %romfile% in your custom command line, it will automatically be 'inserted' as the last argument. Though as I think about it, you could adjust the loop to account for that.  

Also note, what %romfile%returns depends on what you have checked or not (No quotes, File Name only...).

Edited by JoeViking245
  • Like 1
Link to comment
Share on other sites

Yeah I been messing with this the past few days trying to wrap my head around it and today I finally figured it out after some testing and searching. My second attempt gets every possible variable you could need even just the drive letter where the rom was launched.

I have many ideas now and one of them will be possibility of per game configs for any emulator. now that I got the variable hurdle out of the way time to get coding.?

 

  • Like 1
Link to comment
Share on other sites

There are several more variables that can be passed that I forgot to mention as well. Started on my first RocketLauncher module conversion over to LaunchBox with Success!!

Working on Altirra and will be able to have per game settings! Already have things up and running. This is so awesome and it works with my Cinematic startup, shutdown and LB pause screens. Basically now can have RL functionality without even using or needing RL all within LB.

Edited by Krakerman
  • Like 2
Link to comment
Share on other sites

Good News!

Since learning how to pass variables to ahk scripts I been working on a custom launcher for the Altirra (Atari 400/800/5200) emulator. With great success I have the following setup and working within the Launcher script:

  • Custom system settings.
  • Per game settings.
  • Cinematic fades for startup and shutdown and the ability to turn them on/off per game. No longer need to setup via Additional Applications in LB.
  • Default Cinematic Fades for Platforms. So if a game cinematic fade is not found will look for a _Default video for both startup and shutdown.
  • Works with LaunchBox Pause feature.
  • Ability to select the following: hide desktop, taskbar and/or mouse pointer so launching from within LB/BB is seamless. 
  • Cartridge, Disks and Tape images all supported. 
  • All games and platform can be setup and configured via configuration ini file. Gives you more control over how to setup your games for Altirra.
  • Custom location ability for your Cinematic fades.
  • Easy setup in LB. Just setup as an emulator with a command line and that's all! No Plugins ... No RocketLauncher ?
  • To setup each game you will need to edit the ini file using Notepad++ or any text editor.
  • Altirra profiles feature support!

Working on adding more features but currently all the above is working perfectly!

Edited by Krakerman
  • Like 4
  • Game On 1
  • The Cake is a Lie 1
Link to comment
Share on other sites

On 6/27/2020 at 12:11 AM, Krakerman said:

Good News!

Since learning how to pass variables to ahk scripts I been working on a custom launcher for the Altirra (Atari 400/800/5200) emulator. With great success I have the following setup and working within the Launcher script:

  • Custom system settings.
  • Per game settings.
  • Cinematic fades for startup and shutdown and the ability to turn them on/off per game. No longer need to setup via Additional Applications in LB.
  • Default Cinematic Fades for Platforms. So if a game cinematic fade is not found will look for a _Default video for both startup and shutdown.
  • Works with LaunchBox Pause feature.
  • Ability to select the following: hide desktop, taskbar and/or mouse pointer so launching from within LB/BB is seamless. 
  • Cartridge, Disks and Tape images all supported. 
  • All games and platform can be setup and configured via configuration ini file. Gives you more control over how to setup your games for Altirra.
  • Custom location ability for your Cinematic fades.
  • Easy setup in LB. Just setup as an emulator with a command line and that's all! No Plugins ... No RocketLauncher ?
  • To setup each game you will need to edit the ini file using Notepad++ or any text editor.
  • Altirra profiles feature support!

Working on adding more features but currently all the above is working perfectly!

Holy moly! I've been waiting on something like this. I did a private proof on concept very similar to this long ago, but never went as far as you have (because LIFE!). Can't wait to see this, and how it can be extended to other platforms/emus. Thanks so much for the excitement. :)

  • Like 1
Link to comment
Share on other sites

Yeah this is Huge! I can't stress enough about the importance of having this ability. This weekend I discovered and found a bunch of new things with AHK I can do. Added some more new features as well:

  • Separate config files for setting up Disk, Cart and Tape images. Keeps thing much more organized as well as having multiple games with the same name.
  • Cleaned up the code.

Things to do:

  • Add Atari 5200 and XEGS support.
  • Add ability to launch and run basic programs. This can be even more advanced with adding other programming language carts as well.
  • More advanced Altirra options.

 

Edited by Krakerman
  • Like 1
Link to comment
Share on other sites

Now have:

  • Basic programs automatically load and run implemented! (Supports files with .bas format)
  • Created a new config for setting up your basic programs.
  • Implemented the following formats:  .atx, .atr, .bas, .bin, .car, .cas, .dcm, .pro, .rom, .xex, .xfd, .wav
Edited by Krakerman
  • Like 3
Link to comment
Share on other sites

I keep finding new things I can do with AHK and now I have Instruction Cards working within my code! Haven't added animations to it yet but that will be something I will be looking at soon. 

  • Added custom HotKey for turning on/off showing Instuction Card.
Edited by Krakerman
  • Like 2
Link to comment
Share on other sites

Ok, I now added:

  • Added ability to have 4 different sets of instruction cards.
  • Added an option to allow the game to be paused or not when displaying instruction cards.

Looking at adding built-in marquee support via Display Fusion which will allow for animated marquees with gifs or mp4's. I have it up and running but there is a slight delay after launching and exiting game before the marquee changes but it does work.

Reason I was looking at an alternative is because I have a multi monitor setup with 5 monitors and LaunchBox built in marquee support does not work correctly with my setup and this does.

 

 

 

Edited by Krakerman
  • Like 2
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...