Jump to content
LaunchBox Community Forums

Autohotkey Startup/Exit scripts issues


Aevans0001

Recommended Posts

So first I got my first commodore 64 game working using Joytokey and additional apps.  I put a startup app to load joytokey, and then a batch file to kill joytokey after closing emulator.  That worked, however it only worked for the one game.  I need 20,000 C64 games to work.  So I tried an autohotkey script.  So I got the autohotkey to load jpytpkeu amd an exit script to run the bat file.  However, it didn't run the batch file.  So then I tried using the following cod e to kill it.

if WinExist("JoyToKey Ver6.1.1 : Joytokey")
    WinClose ; use the window found above 

this again failed to load upon exit of the emulator.  I have verified both ways worked independently, but not through Launchbox.

------------------------------Edit--------------------------

 

Ok so I got it working, however I would lke to see how to do it the proper way with ahk script in begging and end.  Here is the code I used

 

Run, d:\games\joytokey\joytokey.exe
WinWait, ahk_exe x64.exe
WinWaitClose  ; Wait for the exact window found by WinWait to be closed.
Run, "d:\games\joytokey\joytokeykill.bat"

and here is my version of joytokeykill.bat

taskkill /IM joytokey.exe /F

 

This is specifically for Winvice but you can use it with any emulator, you just change the ahk_exe section

Edited by Aevans0001
Link to comment
Share on other sites

There isn't currently a way to setup an emulator with a 'run before main application' and 'run after main main application ' like you can per game.   However under "Edit Emulator" you can add your script under the "Running AutoHotKey Script" tab. Also, you could add your bat file command to the script instead of calling it.

Run, d:\games\joytokey\joytokey.exe
WinWait, ahk_exe x64.exe
WinWaitClose  ; Wait for the exact window found by WinWait to be closed.
Run taskill.exe /IM joytokey.exe /F,, Hide

 

Link to comment
Share on other sites

  • 1 year later...
9 hours ago, d8thstar said:

my bat file will kill joytokey by rom.  but the above won't kill joytokey when exiting the emu

You must run the bat file while exiting the emulator. Copy/paste to the "Running AutoHotKey Script" tab and change the path to your bat file:

$Esc::
{
Run, D:\Emulators\CloseJoyToKey.bat
WinClose, ahk_exe {{{StartupEXE}}}
}

Or close JoyToKey directly:

$Esc::
{
Process, Close, JoyToKey.exe
WinClose, ahk_exe {{{StartupEXE}}}
}

*Edit*

If you would close an emulator with Escape natively (without an exit script), you could also try:

$Esc::
{
Process, Close, JoyToKey.exe
Send, {Esc down}
Sleep, 150
Send, {Esc up}
}

 

Edited by Koroth
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...