Jump to content
LaunchBox Community Forums

AutoHotkey and auto-key press (ePSXe)


Dormat

Recommended Posts

The problem: Loading some PSX ISOs takes away valuable game-playing time for us with low attention spans and patience.

One solution: Load a save state via command line to get to a game menu more quickly. Unfortunately, this doesn't appear to be an option in ePSXe.

Another potential solution: Load the first save state right at the menu by pressing 'F3'. This seems like something an AutoHotkey script could do but having never used them before, I don't know the ins and outs. Looking at the AutoHotKey docs, I thought the below might work (I added the sleep for 6 seconds after 'Send {F3} didn't work) but no go. Sleep 6000 Send {F3} I added the above to the autohotkey portion of the epsxe emulator definition but it doesn't do anything. I'm not sure how to troubleshoot it. It seems autohotkey is mainly meant to convert one keypress into running a script but in my case, I want it to run regardless.

Are there AHK headers which are necessary to make a script run? Can I just start running commands without a detected keypress to start the script? I'm open to other thoughts ideas also.

Edited by Dormat
Link to comment
Share on other sites

If you're willing to go outside of ePSXe, I'm fairly certain that you can enable auto load/save states on game load/exit in the Mednafen core of Retroarch. I know that standalone Mednafen has it so it's likely that the RA core does as well. Mednafen (and Retroarch for that matter) is seriously awesome. It's much more accurate than ePSXe. There were some games (like Jumping Flash 2, for example, which has lots of weird/missing geometry in ePSXe) that I was convinced were never going to be right unless I broke out a real PS1... then I used Mednafen with them and they're perfect.
Link to comment
Share on other sites

Thanks for the suggestion. I started with retroarch (I use it for most of my roms) but PSX games were painfully slow for some reason. I'll revisit why that might be. ePSXe works pretty great for Crash Bandicoot with HiRes 3D but the 2d textures don't look as good as retroarch probably could with the right filters.
Link to comment
Share on other sites

  • 1 month later...

After working on this more, it seem AHK scripts will only run upon custom LB events: https://www.launchbox-app.com/forum/features/using-autohotkey Now, I'm trying to run an Auto Hotkey script externally with the AHK standalone executable but am running into another problem. - I created a Windows batch script to run my AHK script and ePSXe. - I changed the ePSXe emulator definition to point to my .bat (instead of epsxe.exe). When I try to run a PSX game, I get an LB error.

An error occurred while trying to launch the game. The specified executable is not a valid application for this OS platform.

Here's my batch script:

c:\emulators\utilities\ahk\autohotkey.exe c:\emulators\utilities\epsxe.ahk epsxe %1 %2 %3 %4 %5 %6 %7 %8 %9

Does Launchbox not support batch files?

Edited by Dormat
Link to comment
Share on other sites

Jason, you were correct. Somehow, my batch file was 0 bytes. Thanks! For anyone curious, here's what I ended up with for my ePSXe definition. I used AntiMicro to map the Xbox 360 Guide button (I'm actually using a DS3 controller with Xinput driver) to the ESC key. AM can be used just as easily to map to Alt-F4. NoTrayOrphans is an AutoHotkey compiled EXE used to clean up dead system tray icons from here: https://autohotkey.com/board/topic/80624-notrayorphans

My batch script:

start "AHK" c:\emulators\utilities\ahk\autohotkey.exe c:\emulators\utilities\ahk\epsxe.ahk
start "AM" "c:\Program Files\antimicro\antimicro.exe" --hidden --profile "c:\users\living\documents\AM - Guide button is ESC.amgp"
cd \emulators\psx\epsxe
start "ePSXe-from-script" /WAIT c:\emulators\psx\epsxe\epsxe -nogui -loadbin %1 %2 %3 %4 %5 %6 %7 %8 %9
start "kill AM" /WAIT c:\Windows\System32\taskkill.exe /F /im
antimicro.exe start "kill NTO" /MIN /B c:\emulators\Utilities\NoTrayOrphans.exe

 

My external AutoHotkey script (epsxe.ahk):
=================
SetTitleMatchMode, 2 ; Relax title matching a bit

#Persistent ; Start loop
SetTimer, ePSXeLoadState, 75 ; Wait 75 milliseconds before checking again
return
 
ePSXeLoadState:
IfWinExist, ePSXe - Enhanced PSX emulator
    {
        WinActivate ; Use the window found from 'IfWinExist'
        ; SetTimer, ePSXeLoadState, Off ; Turn the timer off (not needed in this script)
        Sleep, 450 ; May have to lengthen this delay if ePSXe isn't ready to receive input
        ; Send {F3} ; Normal 'Send' operation isn't recognized in ePSXe
        SendInput {F3 down} ; so we use the 'SendInput' Method
        Sleep, 50 ; to load state from slot 1
        SendInput {F3 up}
        Sleep, 500
        SendInput {F2 down} ; Switch to a save slot besides 1
        Sleep, 50
        SendInput {F2 up}
        Sleep, 500
        SendInput {F5 down} ; Enable Analogue control
        Sleep, 50
        SendInput {F5 up}
        Sleep, 100
        ExitApp ; Quit AutoHotKey
    }
else
    return
==================
Edited by Dormat
Link to comment
Share on other sites

  • 1 year later...

Update: The intended use case for this was Crash Bandicoot 2. Unfortunately, I later found that loading a save state in ePSXe also loads a cached read of the PSX memory cards. This causes memory card saves on disk to be ignored; you only see mem card saves at the time the save state was written.

Thus, for now, I've stopped using the save state shortcut in ePSXe. If ePSXe could be configured to not cache mem cards, this would work again.

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