Not sure if I can solve your problem, but a workaround may be to use a tool called 'AutoHotKey'. (http://www.autohotkey.com/)
Basically, what you can do is set up a memory resident program to launch your 'Joy2Key' upon launching of your emulator. The code you would need to set up to run would be to use the 'IfWinActive' / 'IfWinNotActive' functions so that when it detects a program running, it runs the joy2key software to reprogram the keys.
http://www.autohotkey.com/docs/commands/IfWinActive.htm
The code would look something like this:
Loop
{
IfWinActive, FCEUX ;NES emulator for example (replace FCEUX with whatever program you are running (has to be the name in the title bar))
{
Run c:\...\...\joy2key ;replace with the path and options for your program to change keys
}
IfWinNotActive, FCEUX
{
Run c:\...\...\joy2key ;replace with path and options for your program to revert changes when returning to mala
}
}
Thanks for the advice...with a little tweaking to the code you provided I got it working efficiently enough for my tastes. For those interested, here's what the problem I initially encountered was and how I worked around it.
The "loop" command is needed to keep AHK open, but with the script provided the computer is always going to be in one state or the other (the window referred by IfWinActive and IfWinNotActive will ALWAYS be active or not active) so that part of the script would continuously run due to the "loop" function.
To remedy, I wrote the following in (bolded)
Loop
{
IfWinActive, FCEUX ;NES emulator for example (replace FCEUX with whatever program you are running (has to be the name in the title bar))
{
Run c:\...\...\joy2key ;replace with the path and options for your program to change keys
WinWaitClose, FCEUX ;waits for the emulator window to close before continuing the script
run tskill joytokey ;exits the Joy2Key application as it is minimized in the system tray, so can't simply close the window (tskill only on Windows 2000, XP and Vista, I think)
}
IfWinNotActive, FCEUX
{
WinWait, FCEUX ;halts the script until the emulator window is opened again
reload ;launches the script from the beginning
}
}
I am not remotely good at this, but this seems to work well enough. Couple of quick screen flashes as it launches Joy2Key and kills it, but that's an acceptable exchange for being able to exit my NES, SNES and Genesis emulators with the trigger on the N64 pad!
BTW, if anyone can help with the initial pre-command and post-command problem, I'd be interested in utilizing that route simple for aesthetic purposes.
Thanks again g00ber!