Jump to content
LaunchBox Community Forums

Need help from the AutoHotKey gods


DerHof2007

Recommended Posts

 I need an AHK file for my C64 emulation.

This wasn't an issue for me in Hyperspin as I guess Rocketlauncher took care of these issues so I need to figure this out.

I'm running my Launchbox in a cabinet so I need AHK for multiple things. I have to reassign keys for specific games since C64 uses so many keyboard commands.

This is the easy part. I have an AHK file for each game that requires it. I add 'additional app' in the edit game settings point to its specific AHK file.

If I want my button that is programmed for x to be a j I simply put x::j in to the AHK file...

My issue comes with exiting a game. The exit button on my cabinet is escape. Zombeaver got me pointed in the right direction but I need a little further help.

I need my escape button to not only exit the game/emulator but also shut down AutoHotKey as well.... if its still running then my keys will be all messed up after the game.

1st problem is escape does not exit Winvice... I need altX to do that. escape::!x

Also I need to have escape exit AHK....

Escape::
Process,close,AutoHotkey.exe
return

These will both work perfectly fine on their own... I need to combine them into one key press.

This is what I've tried.

First method

$Escape::
{
   Send {!x}
   KeyWait, Escape
   Send { Process,close,AutoHotkey.exe }
}
return

 

Method 2

escape::
Send {!x}
Sleep, 500
Send {Process,close,AutoHotkey.exe}
Return

 

So technically both of these methods do work... just not for what I need.

If I take both of the commands !x and Process,close,AutoHotkey.exe and swap them out for example the letters m and n then that is exactly what the escape key will do. I'll get those 2 keystrokes from a single escape press.

I can't get AltX (!X)

or AHK exit (Process,close,AutoHotkey.exe)

to work no matter what I try.

Like I said if I just put single keystrokes in there it works fine. Any single key stroke combined with the AltX or the exit command then I get the keystroke but not the other.

The commands will work on their own though

escape::!x

Escape::
Process,close,AutoHotkey.exe
return

Sooooo, how can I make this work?

Edited by DerHof2007
typo
Link to comment
Share on other sites

escape::
Goto, close

close:

{
Send !x
Exitapp

}

 

or

 

escape::
Process, Exist,  Commodore.exe
If ErrorLevel <> 0
    Process, Close,  Commodore.exe
Exitapp

 

or

 

escape::
Process, Exist,  Commodore.exe
If ErrorLevel <> 0
    Process, Close,  Commodore.exe

Process, Exist,  Autohotkey.exe
If ErrorLevel <> 0
    Process, Close,  Autohotkey.exe

 

Change "Commodore.exe" to whatever your emulator process.

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

Follow up question. So worse case scenario I am going to have to make an AHK file for every C64 game I have. I assumed I would have to do this anyway and I only have 66 roms so not the end of the world.

But then I saw that in the emulator settings I could assign an AHK script. So using what you just gave me I did that and now every game will close the emulator with the escape key.

But if I also assign a game specific AHK for specific game keys... they will work. And escape still exits... but the game specific AHK does not close.

I notice using your script only assigned to the emulator that I don't get an AHK icon in the notification area... but for the game specific AHK files I do.... and that is what does not close if I have the universal emulator AHK set up.

I tried the game specific with only game keys and also with your script as well (which actually makes it doubled up)... but neither way closes the game specific file... the AHK notification icon remains.

So some games I don't really have to reassign anything and using the universal script in the emulator settings would make it so I don't have to create an AHK file for every game.... Any thoughts?

But like I said this isn't really a big issue... I assumed I would need an AHK for every game and I could have made 20 of them in the time it took me to type this post but sometimes it fun to just try and figure things out...

 

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