What I'm thinking: It would be nice if a program running outside of MAME had a way to tell the lightbike stage apart from other stages
You can do this with AHK (I've done something very similar to this) provided the following 3 things are true:
1) There is some portion of the screen that is exactly the same everytime the lightbike stage comes up and is not that way anywhere else in the game.
2) There is some portion of the screen that is exactly the same everytime the lightbike stage is finished.
3) You don't mind doing some work.

Take screen shots using the printscreen key to satisfy both 1 and 2. Use paint to cut out just the part of the image you need - the part that is always the same. Make sure you save them as bitmaps. Let's call them lightBikeBegin.bmp and lightBikeEnd.bmp
Then try this script:
Loop
{
<run batchfile to switch to 8 way>
Loop
{
ImageSearch,,, X1, Y1, X2, Y2, lightBikeBegin.bmp
If (ErrorLevel = 0)
{
break
}
}
<run batchfile to switch to 4 way>
Loop
{
ImageSearch,,, X1, Y1, X2, Y2, lightBikeEnd.bmp
If (ErrorLevel = 0)
{
break
}
}
}
$esc::
send {esc}
exitapp
If you're not already familiar with imagesearch, see the relevant section in the AHK help file.
Basically this script sets it to 8 way, then the first imagesearch loop waits to see the lightbike part, that loop exits and sets it to 4 way, then the second imagesearch loop waits to see the lightbike part end, then jumps back to the top of the main loop to set to 8 way and start the process again. The esc hotkey allows you to exit mame and the script by pressing escape. Obviously you need to change this if you use something other than escape to exit mame.
A couple of points:
The image on screen must match your bitmap image EXACTLY. So if you fiddle with mame's brightness, try some new scanlines or change your resolution, the script will stop working.
The portion of the screen you search for should be as small as possible. You don't want the script to spend time searching a part of the screen where the image does not appear, because then the image may go away before the script sees it.
This should work for you if you want to take the time to try it out.
