Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Save HighScores when shutting down with MAME open  (Read 1877 times)

0 Members and 1 Guest are viewing this topic.

Steveearle86

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 10
  • Last login:November 26, 2017, 05:10:06 am
  • I want to build my own arcade controls!
Save HighScores when shutting down with MAME open
« on: February 05, 2017, 01:04:42 pm »
Hi all,
I have a working Attract Mode / MAME arcade machine with MAME Hiscore running on Windows 7.

This works great and when I exit MAME back to Attract Mode, the hiscore board changes are saved. However, if I shut the machine down with MAME running, the changes to the hiscore board are not saved, presumably the save function is triggered on MAME exit and when shutting down, this is bypassed and MAME is shutdown "ungracefully"

I want to (if possible) make it so that when I shutdown the PC from MAME, the scoreboard is saved. I thought maybe I could send an exit command to MAME on shutdown so I created a VBScript which sends an escape key command and used gpedit to run this on both shutdown and log off (the escape key should cauase MAME to exit and therefore saving the hiscore) but this has not worked (i assume it is being run after MAME has been closed by the shutdown)

The cabinet has a button that is wired to the power header of the motherboard and is used to startup / shutdown the PC.

Does anyone have any ideas of how I can do this, clearly at the moment, the workaround is always to escape to the menu before shutting down but would like to not have to remember to do this

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2943
  • Last login:August 14, 2023, 02:00:48 am
  • 0x2b|~0x2b?
Re: Save HighScores when shutting down with MAME open
« Reply #1 on: February 05, 2017, 01:30:55 pm »
You can't send keys to MAME because it uses Raw Input. You can compile MAME to use DirectInput but there is an easier way. Check out ProcessUtil and try it with the command line option to send the WM_CLOSE message to close MAME "gracefully".

Steveearle86

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 10
  • Last login:November 26, 2017, 05:10:06 am
  • I want to build my own arcade controls!
Re: Save HighScores when shutting down with MAME open
« Reply #2 on: February 05, 2017, 09:40:51 pm »
Thanks for your help. I will give this a try tomorrow. Looks like I wouod create a batch file with the command "process -q mame.exe" and run that via gpedit

Steveearle86

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 10
  • Last login:November 26, 2017, 05:10:06 am
  • I want to build my own arcade controls!
Re: Save HighScores when shutting down with MAME open
« Reply #3 on: February 06, 2017, 08:19:42 am »
Ok, I have downloaded the utility and tested as follows:

Open MAME,
Open command prompt
run following command in command prompt -
Code: [Select]
"C:/process.exe" -q mame64.exethis is fine when in MAME's game selection list and closes MAME straight away, however, when I try running the above command in the prompt when MAME is playing a game, it times out and says
Code: [Select]
"mame64.exe (PID 15408) failed to respond to WM_CLOSE. Terminating Now."
Is something else running when MAME loads a game that needs to be closed first?

Unortunately, a Google search hasn't brought much clarity

Steveearle86

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 10
  • Last login:November 26, 2017, 05:10:06 am
  • I want to build my own arcade controls!
Re: Save HighScores when shutting down with MAME open
« Reply #4 on: February 06, 2017, 12:11:52 pm »
OK I have done so more testing. I created a batch file with the line

Code: [Select]
"C:/process.exe" -q mame64.exe >> C:/test.txt and set it as both the log off and shutdown script using gpedit

If I open mame and then shut down, and then restart and look in the text file above I can see two entries (since the script is running at both log off and shutdown) but each time it says the mame64.exe process does not exist, this makes me think Windows has already killed the task before the log off script is run?