Jump to content
LaunchBox Community Forums

Auto Hotkey Scripts


Lordmonkus

Recommended Posts

2 hours ago, JoeViking245 said:

I think I might have accidently discovered something.

#SingleInstance force

Image = M:\Giochi\Utility\Launchbox\ThirdParty\AutoHotkey\Scripts\Ps3-Scripts\ps3_splash.png
Options = Zw%A_ScreenWidth% Zh%A_ScreenHeight%

SplashImage,1:%Image%,b %Options%,,,MySplash
WinMove, MySplash,,0,0, %A_ScreenWidth%, %A_ScreenHeight%

WinMinimize, ahk_exe LaunchBox.exe,
WinMinimize, ahk_exe LaunchBox.exe,
WinMinimize, ahk_exe BigBox.exe, 
WinMinimize, ahk_exe BigBox.exe

MouseMove, 1920, 1080

#IfWinExist MySplash
{  
   1Joy1::
   1Joy2::
   1Joy3::
   1Joy4::
   1Joy5::
   1Joy6::
   1Joy7::
   1Joy8::
   1Joy9::
   1Joy10::
   1Joy11::
   1Joy12::
   {
     Sleep 100
     SplashImage,1:off
     WinRestore, ahk_exe LaunchBox.exe
     WinRestore, ahk_exe BigBox.exe
     ExitApp
   }

   ::
   {
   }
}

Adding the last "::" section I think makes it so any other input does nothing.  This little discovery (assuming it's correct) might have come in handy a long time ago. lol

Conflict resolved. I can spam any button and that's fine.
The problem, however, is that when there is no disc inserted, Bigbox often loses focus and therefore the keys no longer work.
On the other hand, when the disc is inserted, the game starts, but I continue to hear the audio of the bigbox preview video in the background.

In this case below I have not inserted the usb disk, I keep spamming buttons, bigbox loses focus on the second attempt

Link to comment
Share on other sites

@Sbaby

Ok this has been horrible and time consuming - but educational

Its not perfect and if you spam the load button before the first screen comes up then you get stuck in a loop - but I cannot get it any better - it also requires you to make some more artwork

It also needs 2 ahk's to run - well the way I have done it does but please feel free to correct it - you will also need to correct some file paths and sleeps for your own system

I have uploaded the ahks as they have got long and its just easier

You want to set Sony Playstation 3.ahk as the additional app to run before and wait for exit - you can rename it to whatever your current ahk is called if that is easier and saves you having to redo all the additional app stuff again

Put the 2 ahk's into the same folder - I have assumed you have used the following path

M:\Giochi\Utility\Launchbox\ThirdParty\AutoHotkey\Scripts\Ps3-Scripts\

Step 1 - Download the files and put into the above pathway

Step 2 - Make an image for whilst the ahk checks that the External hard drive is connected

Step 3 - Make an image to tell you when the hard drive ISN'T connected - we are no longer using the nice inbuilt pop up because it was causing focus issues

Step 4 - Open Sony Playstation 3 Part 2.ahk in notepad+ or whatever you use and change than names of the two images to be whatever you just called them

Step 5 - Turn off start up screens

Step6 - - Paste the following into running ahk

WinMinimize, ahk_exe LaunchBox.exe,
WinMinimize, ahk_exe LaunchBox.exe,
WinMinimize, ahk_exe BigBox.exe, 
WinMinimize, ahk_exe BigBox.exe


Esc::
WinClose, ahk_exe {{{StartupEXE}}}
WinRestore, ahk_exe LaunchBox.exe
WinRestore, ahk_exe BigBox.exe
ExitApp

 

----------------------------------------------------------------------------------------------------

The following happens

You press play on game

Image one reminds you to attach hard drive and then press any button

Image 2 comes up - this is checking that the hard drive is there and loading the game - basically covers up the loading of the emulator and makes it look nice and pretty again 

 -this has a error level set to 10 seconds - so basically if waits 10 seconds for emulator to start up and if it doesn't it goes to image 3, but if the emulator does start up it goes to the game instead - you can change this timing but I used 10 seconds for testing as it always worked - line 20 basically change the 10 to however many seconds you need/want

If you change the Sleep on line 35, you can get the emulator to show up sooner or later depending on your computer speed

Image 3 only comes up if you haven't put the hard drive on - it replaces the pop up from Launchbox - so needs to say something like - you didn't connect the hard drive!!! This image stays up for 2 seconds at the moment and then goes straight back to LaunchBox if you want it to stay up longer then increase lines 66 & 81 to higher than 2000.

Good luck with it all.

Like I said only issue my end is if you spam the load button as the first image comes up but I cannot stop that happening no matter what I do

 

Oh and if @JoeViking245 can make this clean and tidy and better then please feel free to 

 

 

 

Edited by Kiinkyfoxx
Improving it
Link to comment
Share on other sites

2 hours ago, Kiinkyfoxx said:

@Sbaby

Ok this has been horrible and time consuming - but educational

Its not perfect and if you spam the load button before the first screen comes up then you get stuck in a loop - but I cannot get it any better - it also requires you to make some more artwork

It also needs 2 ahk's to run - well the way I have done it does but please feel free to correct it - you will also need to correct some file paths and sleeps for your own system

I have uploaded the ahks as they have got long and its just easier

You want to set Sony Playstation 3.ahk as the additional app to run before and wait for exit - you can rename it to whatever your current ahk is called if that is easier and saves you having to redo all the additional app stuff again

Put the 2 ahk's into the same folder - I have assumed you have used the following path

M:\Giochi\Utility\Launchbox\ThirdParty\AutoHotkey\Scripts\Ps3-Scripts\

Step 1 - Download the files and put into the above pathway

Step 2 - Make an image for whilst the ahk checks that the External hard drive is connected

Step 3 - Make an image to tell you when the hard drive ISN'T connected - we are no longer using the nice inbuilt pop up because it was causing focus issues

Step 4 - Open Sony Playstation 3 Part 2.ahk in notepad+ or whatever you use and change than names of the two images to be whatever you just called them

The following happens

You press play on game

Image one reminds you to attach hard drive and then press any button

Image 2 comes up - this is checking that the hard drive is there and loading the game - basically covers up the loading of the emulator and makes it look nice and pretty again 

 -this has a error level set to 10 seconds - so basically if waits 10 seconds for emulator to start up and if it doesn't it goes to image 3, but if the emulator does start up it goes to the game instead - you can change this timing but I used 10 seconds for testing as it always worked - line 20 basically change the 10 to however many seconds you need/want

If you change the Sleep on line 35, you can get the emulator to show up sooner or later depending on your computer speed

Image 3 only comes up if you haven't put the hard drive on - it replaces the pop up from Launchbox - so needs to say something like - you didn't connect the hard drive!!! This image stays up for 2 seconds at the moment and then goes straight back to LaunchBox if you want it to stay up longer then increase lines 66 & 81 to higher than 2000.

Good luck with it all.

Like I said only issue my end is if you spam the load button as the first image comes up but I cannot stop that happening no matter what I do

 

Oh and if @JoeViking245 can make this clean and tidy and better then please feel free to 

 

Sony Playstation 3.ahk 1.1 kB · 1 download Sony Playstation 3 Part 2.ahk 2.19 kB · 1 download

Thank you so much for your support

I have ps3_splash.png and ps3_splash2.png, I configured the first AHK with these options:

error.thumb.jpg.18c58fa15104829895309b48604d85ce.jpg

 

For now I have not inserted the usb disk.

And unfortunately when I press the button I only see a small graphic error and then several seconds pass, see video (pression of button at time 0:06)

 

Edited by Sbaby
Link to comment
Share on other sites

14 minutes ago, Sbaby said:

And unfortunately when I press the button I only see a small graphic error

This doesn't answer anything, may help in troubleshooting. 

At 6 seconds, it looks like it's doing the SplashImage command (again) right before the WinMove command. And loading the same image.

image.thumb.png.1ae1ea040a7c463338cebb0dc1ed675f.png

 

just like you see it do at 18 seconds

image.thumb.png.fe42207f3b5382058f88da2449bb5d79.png

But this time loading the next image.

Link to comment
Share on other sites

I think you are missing the 2nd image. You should have 3 in total

Image 1- INERISCI L "HARD DISK ESTERNO USB "PS3 GAMES"" POI PREMI UN TASTO PER CONTINUARE 

*****Image 2-VERIFICA DEL DISCO RIGIDO ESTERNO****** MISSING IMAGE??

Image 3-DISK ESTERNO USB NON INSERTIO GIOCO NON TROVATO PRMI UN TASTO PER CONTINUARE

Also you don't need to press a button on the 3rd screen to continue - unless you have changed the ahk

@JoeViking245 with the win - I took too long using Google translate to figure stuff out!!! So actually I think @Sbaby might be using the same image for image 1 and 2 ? I originally had 3 images and played around to make the jumps minimal - but I don't think it will ever be completely smooth - well not with my skill level at least

Edit:

To be fair re-reading my ahk and instructions I can see how it would happen  with being an image short - I will change the original post and put in some extra info just in case someone else ever wants or needs this again.

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

  • 3 weeks later...

Thank you very much for all your advice, now ps3 and wii work perfectly. I need now to free up hard disk space but I don't want to permanently delete some old abandonware pc-games that I have finished, I want to compress some folders of some of my windows games with a self-extracting (for example winrar) and place them zipped files in a cloud drive. I would like that with launchbox, if it did not find the executable it would propose a splash screen indicating that it sends me directly to the cloud site for download. How can I do to make an AHK that does something only if it does not find the executable rom? But I would like to do it generic and not for every single game

Link to comment
Share on other sites

On 10/31/2021 at 10:33 PM, Sbaby said:

Thank you very much for all your advice, now ps3 and wii work perfectly. I need now to free up hard disk space but I don't want to permanently delete some old abandonware pc-games that I have finished, I want to compress some folders of some of my windows games with a self-extracting (for example winrar) and place them zipped files in a cloud drive. I would like that with launchbox, if it did not find the executable it would propose a splash screen indicating that it sends me directly to the cloud site for download. How can I do to make an AHK that does something only if it does not find the executable rom? But I would like to do it generic and not for every single game


someone can advise me something for this 👆

 

 

------

 

 

in the meantime I wanted to ask everyone, and especially to @JoeViking245 and @Kiinkyfoxx
I created a fantastic system for super punchout and dual monitors, taking the script similar to the one made for wii.
As you can see it works very well, in this case I chose a single monitor with button 1, the choice two with two monitors also works well.
My only problem is that sometimes I keep hearing the music of the launchbox preview video superimposed on the mame while I play and it is annoying, why do you think?

 

 

 

I have set an application that starts automatically before starting the game so in this script there is no emulator because at the exit it starts mame default of launchbox

 

SCRIPT :

 

 

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance force

Image = M:\Giochi\Utility\Launchbox\ThirdParty\AutoHotkey\Scripts\MAME\spnchout_splash_0start.png
Image2 = M:\Giochi\Utility\Launchbox\ThirdParty\AutoHotkey\Scripts\MAME\spnchout_splash_2.png
Image3 = M:\Giochi\Utility\Launchbox\ThirdParty\AutoHotkey\Scripts\MAME\spnchout_splash_1.png
Options = Zw%A_ScreenWidth% Zh%A_ScreenHeight%
;Options = Zw1920 Zh1080


SplashImage,1:%Image%,b %Options%,,,MySplash
WinMove, MySplash,,0,0, %A_ScreenWidth%, %A_ScreenHeight%

WinMinimize, ahk_exe LaunchBox.exe,
WinMinimize, ahk_exe LaunchBox.exe,
WinMinimize, ahk_exe BigBox.exe, 
WinMinimize, ahk_exe BigBox.exe,

MouseMove, 1920, 1080

#IfWinExist MySplash
   {
   1Joy4::
   $2::
   {
FileCopy, M:\Giochi\Emulatori\MAME\CFG\spnchout.cfg_2monitor, M:\Giochi\Emulatori\MAME\CFG\spnchout.cfg,1
FileCopy, M:\Giochi\Emulatori\MAME\ini\spnchout.in#2monitor, M:\Giochi\Emulatori\MAME\ini\spnchout.ini,1
MouseMove, 1920, 1080
    SplashImage,2:%Image2%,b %Options%,,,Splash2
WinMove, Splash2,,0,0, %A_ScreenWidth%, %A_ScreenHeight%
    WinWait, Splash2
    SplashImage,1:off
    SetTimer, Image2, on,
    Sleep 3000
    Gosub, Exit
   }

   1Joy3::
   $1::
   {
FileCopy, M:\Giochi\Emulatori\MAME\CFG\spnchout.cfg_1monitor, M:\Giochi\Emulatori\MAME\CFG\spnchout.cfg, 1
FileDelete, M:\Giochi\Emulatori\MAME\ini\spnchout.ini
MouseMove, 1920, 1080
    SplashImage,3:%Image3%,b %Options%,,,Splash3
WinMove, Splash3,,0,0, %A_ScreenWidth%, %A_ScreenHeight%
    WinWait, Splash3
    SplashImage, 1:off
    SetTimer, Image3, on,
    Sleep 3000
    Gosub, Exit
   }

}
 
Exit: 
ExitApp

Image2:
Sleep, 3000
SplashImage, 2:off
SetTimer, Image2, off,
return

Image3:
Sleep, 3000
SplashImage, 3:off
SetTimer, Image3, off,
return

Link to comment
Share on other sites

12 hours ago, Sbaby said:

sometimes I keep hearing the music of the launchbox preview video superimposed on the mame while I play

Only 2 things I can think of.

When your doing a bunch of testing, (i.e.  start LB [once], launch a game that starts a script then continues to the game, exit game, modify script, launch that game again.... over and over and over) occasionally [not necessarily after EVERY change] exit LB and then restart it.  After exiting, check that you don't have any spurious AHK scripts lingering in the background (still running).

When you Minimize LB/BB at the beginning of your script, you may want/need to restore it (them) just before your ExitApp.

Link to comment
Share on other sites

On 10/31/2021 at 2:33 PM, Sbaby said:

Thank you very much for all your advice, now ps3 and wii work perfectly. I need now to free up hard disk space but I don't want to permanently delete some old abandonware pc-games that I have finished, I want to compress some folders of some of my windows games with a self-extracting (for example winrar) and place them zipped files in a cloud drive. I would like that with launchbox, if it did not find the executable it would propose a splash screen indicating that it sends me directly to the cloud site for download. How can I do to make an AHK that does something only if it does not find the executable rom? But I would like to do it generic and not for every single game

For what you're asking, the only way to check if a certain rom file exists is to change (create new) your emulator to an AHK script (or similar).  You can't pass the path/rom_file to an Additional App.

The AHK script you create as the emulator will see the path/rom_file.ext as  %1%.

You can then check for the file with something like   if FileExist("%1%")

 

Link to comment
Share on other sites

Actually you can setup an emulator as an AHK within LaunchBox and pass these variables %launchboxbigboxexepath%, %romfile%, %platform%, and %FULL\PATH\TO\ROM\FILE

Look at example to see how to setup:

image.thumb.png.c45b1760cd576c52a1801ad3418c81ae.png

Your AHK becomes a launcher to launch the emulator. 

 

 

Edited by Krakerman
Link to comment
Share on other sites

To get the variables that were passed to the AHK Launcher from LaunchBox use these lines of code within your AHK Launcher script:

 launchboxPath := param in A_Args[1]
 romPath := param in A_Args[2]
 platformName := param in A_Args[3]
 
 SplitPath, launchboxPath,, launchboxFolder
 SplitPath, romPath, romName, romDir, romExt, romName_noExt, romDrive

 

 

Edited by Krakerman
Link to comment
Share on other sites

On 11/8/2021 at 1:16 PM, JoeViking245 said:

Only 2 things I can think of.

When your doing a bunch of testing, (i.e.  start LB [once], launch a game that starts a script then continues to the game, exit game, modify script, launch that game again.... over and over and over) occasionally [not necessarily after EVERY change] exit LB and then restart it.  After exiting, check that you don't have any spurious AHK scripts lingering in the background (still running).

No, on exit I have no other scripts running.

 

On 11/8/2021 at 1:16 PM, JoeViking245 said:

When you Minimize LB/BB at the beginning of your script, you may want/need to restore it (them) just before your ExitApp.

I don't have to restore lb/bb when exiting the script because at that moment the game starts, so lb/bb must be turned down

 

On 11/8/2021 at 2:17 PM, Krakerman said:

As you can see using the AHK SplitPath command you can get more variables that can be very useful when creating your own launcher.

Thank you for all your valuable very useful informations. I'll try to use them

Link to comment
Share on other sites

  • 2 weeks later...

Apologies in advance if this is the wrong forum/topic to discuss as it's not necessarily LB related.

Generated a basic script to backup/set/restore controller mapping configurations/mapping files for each emulator used. For my setup, intent is to use a set of files for 2-player Tanksitck use and the other for 2-player XBox One use.

Would like to switch between Tankstick and XBox controllers via AHK. Or is another more elegant or existing solution/feature available that I'm not aware of?

Edited by xdmanalo
Link to comment
Share on other sites

  • 4 weeks later...

Hello —

How would I record the romPath variable to an ahk script?

Basically, I'm trying to play the same game on multiple RetroArch's. That way I can play (2) 1-player games at the same time. For example, Pokemon LeafGreen twice.

Currently, I set up (2) RetroArch folders, created an emulator that references RetroArch1, and within the RetroArch1 ahk Running Script, I added the second RetroArch location for reference, but I can't pull the same romPath location. Any ideas?
 

launchboxPath := param in A_Args[1]
romPath := param in A_Args[2]
platformName := param in A_Args[3]
 
SplitPath, launchboxPath,, launchboxFolder
SplitPath, romPath, romName, romDir, romExt, romName_noExt, romDrive

Run, E:\_arcade\LaunchBoxPortable\Emulators\RetroArch2\retroarch.exe romPath

 

Link to comment
Share on other sites

9 hours ago, whazzzzzup17 said:

How would I record the romPath variable to an ahk script?

You can't pass LaunchBox variables to a Running AutoHotkey Script (nor an Additional App).

To do what you want (one method at least) is to create an AHK script that 'is your emulator'.

image.thumb.png.80db9e9cd6634a99de6f7275f6719f07.png

If you need to pass the full/path/to/the/romfile.exe, uncheck the 2 boxes.

Then in CustomEmulator.ahk

Run, E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1\retroarch.exe "%1%"
RunWait, E:\_arcade\LaunchBoxPortable\Emulators\RetroArch2\retroarch.exe "%1%"

RunWait on the 2nd instance keeps the script 'running'. Otherwise, it would launch the 2 instances and close, LB would see that as the emulator exiting and you get the "Thank you for Playing" shutdown screen right away.

Not sure what this does for pause screens or exiting RA, but should get you in the right direction.

Link to comment
Share on other sites

1 hour ago, JoeViking245 said:
Run, E:\_arcade\LaunchBoxPortable\Emulators\RetroArch1\retroarch.exe "%1%"
RunWait, E:\_arcade\LaunchBoxPortable\Emulators\RetroArch2\retroarch.exe "%1%"

RunWait on the 2nd instance keeps the script 'running'. Otherwise, it would launch the 2 instances and close, LB would see that as the emulator exiting and you get the "Thank you for Playing" shutdown screen right away.

Not sure what this does for pause screens or exiting RA, but should get you in the right direction.

For some reason, my LaunchBox can't locate the ahk file, I setup the settings the same as yours. I also moved the files to the main E drive to see if that would work. Not sure what -L means on the error.

Script file not found: E:\-L

image 1.jpg

image 2.jpg

Edited by whazzzzzup17
added images
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...