This is real real quick and dirty. I have a set of ServoSticks from ultimarc that can change the gate from 4 way to 8 way joy sticks. I wrote this for in use with launchbox/bigbox. As far as I can tell there is no way to run extra programs on a per game basis outside of command line options for mame.
This will also kill mame64.exe after 3 min of inactivity so if someone launches a game and walks away it will go back to the launchbox/bigbox launcher. In addition, it will also disable the escape key unless mame is running to prevent people from going to the bigbox menu. After googling for a while I was unable to find a way to do any of this within launchbox.
The install folder for JoyTray from Ultimarc must be set in the windows PATH.
This will monitor a file called joycontrol.txt to determine if the sticks should be set as 4 way or 8 way on game launch. The formatting is stupid simple, all you need is a keyword from the game then ',' and either 4 or 8 to designate 4 way or 8 way.
Here is a sample of what my joucontrol.txt looks like:
1942,8
1943,8
720,8
bubble,4
burger,4
centipede,8
The game name does not need to be exact, just a keyword to match is fine. I have not run into issues where something like "Game1" is 4 way but the sequel "Game2" is 8 way.
There is virtually no error handling, because I am lazy. It's only for mame64 because also I'm lazy, and 3 min is hard coded also again because I am lazy.
The RAR file includes the autoit compiler as well if you want to make changes. For some reason I can't attach files, I just get an error, below are the link
https://pastebin.com/MisuZ71X
https://ufile.io/g6c79
Edit: The binary is in the rar file