Yup, since MAME/MESS gets the input closer to the source before it's processed through windows, software generated keystrokes aren't seen.
If you're capable of compiling your own, there are tutorials out there of changing it in the MAME source code. It's a one line change.
I haven't seen it done in MESS, but I would think the line of code would be the same and could be found by doing a search.
RacerMAME is a build of MAME made for racing cabs. For the sake of other programs/scripts helping with shifter issues, it has the change already made.
I know the xml it generates will only list the driving games. Not sure what other issues you might run into using it, but it's already compiled and ready to go.
While MAME doesn't see virtual key presses, it does see virtual gampad presses.
This is the route I'd take. Either using Headkaze's vjoy program (make sure you get the one made by headkaze and not the knock-off), or directly in autohotkey.
I'd need a refresher on posting gamepad presses in ahk.