Autohotkey instances get left behind when there are problems, not cleaned up during startup/shutdown routine

Issue #5779 new
tastyratz created an issue

When LB has issues, is closed non gracefully, or maybe encounters unexpected conditions in some way it seems to leave AHK’s running in the background. Maybe some of this has to do with the AHK running itself or within LB. Sometimes I find a dozen copies in task manager.

This should easily be cleaned up because there should not be any instances of AutoHotKey.exe running from within the LB directory already open upon launching LB or keep track of PID’s upon process creation.

It might make sense to ensure that on launch and graceful close any copies of that exe are terminated as good housekeeping to prevent unexpected results on that pc?

This has been from when I started on 11.3 to 11.8 on a windows 10 pc.

Comments (6)

  1. Retro808

    How exactly are you running your AHK?

    If LB or BB crashes and you are in the LB or BB UI the AHK used in conjunction with a game (or an emulator) should have already been closed at that point. If you are finding multiple instances of AHK opened in the task manager that is a good indication something might be wrong with the AHK itself.

    It would be helpful if you provide some details on how you are using scripts if it is outside of the typical AHK placed in the Manage Emulators screen.

  2. tastyratz reporter

    When troubleshooting or testing platforms that are problematic is when I typically see the executables really stack up.

    I’ve used them independently of the FE in the past, but, not so much since LB. The only scripts being used while this is happening are AHK’s in the manage emulators screen.

    It is absolutely possible my AHK skills are poor, but, wouldn’t that likely be frequently encountered?

    AHK spawned process tracking and terminating them out of expected conditions would help amateur users from experiencing unexpected results through confining them to the window of use.

  3. Retro808

    What emulators are problematic that this is occurring and what is the script. Some examples would help.

    We have really not seen users report the issue you are requesting a feature for so it is not something that seems to common. The crashes you experience is this a crash in game or crash when in the LB/BB UI? Or both?

    just looking to get more specific details since as mentioned users are not reporting this issue.

  4. tastyratz reporter

    I ended up doing a ton of testing tonight and while I noticed it chasing emulators with problems/bad games, it was actually Dolphin that caused the issue.

    I had a custom close script setup for Dolphin. Every time launchbox was run an AutoHotkey.exe was spawned. I could open and close as many Dolphin games as I want and it only left 1 exe behind. If I close and open LB/BB then the next launch creates another instance. I would go into BB, play a game, then close bb to switch to desktop mode and make changes, then go back. Over time that stacked up a lot of running instances.

    For whatever reason my bad script had bad behavior. I remapped the Esc to close the window because I had remapped controls within dolphin itself to the controller. It was really a basic close script:

    $Esc::
    {
    WinClose, ahk_exe {{{StartupEXE}}}
    }
    

    This one drove me nuts because it also held my escape key hostage where I only navigated back in BB via the controller without it functional.

    I suppose it’s 2 fold. The issue was my fault. Should LB/BB allow a bad AHK script it launched to linger after a successful and clean close of LB/BB?

    As seen by my captured escape key, it can lead to unexpected behavior.

  5. Retro808

    Is the script you posted the one you are saying is the bad script?

    $Esc::
    {
    WinClose, ahk_exe {{{StartupEXE}}}
    }
    

    If not, can you post the bad script?

    If the one you posted is the one you are saying was causing the issues, you may have something else going on. That script has been used for years with no other posts about it causing issues.

  6. tastyratz reporter

    That is the script minus the spaces and comment lines. When I remove it from the exit script tab the AHK orphans stopped being created. When I added it back, they started happening again.

    I do use it successfully for other emulators. By bad, I mostly meant the behavior and result. In retrospect, I suppose that one shouldn’t technically be considered “bad”.

  7. Log in to comment