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: How to use autohotkey to quit emu with ALT+F4 as exit?  (Read 9312 times)

0 Members and 1 Guest are viewing this topic.

Turnarcades

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1973
  • Last login:May 13, 2017, 08:14:29 am
  • Craig @ Turnarcades
    • Turnarcades
How to use autohotkey to quit emu with ALT+F4 as exit?
« on: August 23, 2012, 01:26:30 pm »
OK folks, so I confess, I've gone as far as I can adding emulators to my setup and now getting stuck on the more tricky ones. I know nothing bout autohotkey or anything like that so forgive the noob question, but I need some help with nullDC.

I've got it launching OK, auto-loading the rom I need no problem. All I need to get round is the pesky fact it uses ALT+F4 to quit - and obviously I want it to go to 'Escape'. Can anyone tell me how to do this, very simply, with a step-by-step?

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9272
  • Last login:Yesterday at 06:05:14 am
  • ...
Re: How to use autohotkey to quit emu with ALT+F4 as exit?
« Reply #1 on: August 23, 2012, 01:45:58 pm »
Simplest way=

Code: [Select]
ESC::
Process, Close, nulldc.exe

Throw that in your startup folder.  It will run all the time, but won't bother anything.
You can repeat the second line as many times as you want, substituting other emulators that won't close on ESC.

Another option is the program Closemul.
You'd just put it in the same folder as the emulator and add closemul.exe to the beginning of your command line.
(set the exit keys and app in closemul.ini)


Turnarcades

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1973
  • Last login:May 13, 2017, 08:14:29 am
  • Craig @ Turnarcades
    • Turnarcades
Re: How to use autohotkey to quit emu with ALT+F4 as exit?
« Reply #2 on: August 23, 2012, 06:08:59 pm »
Thanks Badmouth. A straightforward, simple answer. Ain't had much luck with other questions recently. Either I'm trying to do some complex stuff or finding holes in emulators that could easily be sorted but no-ones asked about! I'll give what you've suggested a whirl, firstly with closemul.

Turnarcades

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1973
  • Last login:May 13, 2017, 08:14:29 am
  • Craig @ Turnarcades
    • Turnarcades
Re: How to use autohotkey to quit emu with ALT+F4 as exit?
« Reply #3 on: August 23, 2012, 07:13:58 pm »
Well closemul seems to do the trick nicely and will exit with the escape key, so thanks for that! It took some figuring out to get the correct commandline argument for the frontend .ini file, but it does indeed work.

However (there's always a 'but'! lol), NullDC has a crappy habit of often crashing when closed from fullscreen for some reason. It did this before I had the closemul section added, though not all the time, and even if I eliminate the (this program had to close unexpectedly' message box, the next game I launch only launches windowed, despite my setting in the emulator's .cfg to always launch fullscreen. Any ideas?

nitz

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 507
  • Last login:November 24, 2015, 07:57:29 pm
Re: How to use autohotkey to quit emu with ALT+F4 as exit?
« Reply #4 on: August 23, 2012, 11:59:36 pm »
I'm guessing a workaround would be to go to windowed mode before exiting? If that's the case, try something like this.

Code: [Select]
DetectHiddenWindows, on

#IfWinActive, WinTitle

esc::
WinHide, WinTitle
send !{enter}
sleep 1000
WinClose, WinTitle
return

This should go to windowed mode before closing, but you won't see it, so it'll appear to exit normally, but hopefully stop the crashing problem.

WinTitle is the name of the emulator window, with matching behavior determined by SetTitleMatchMode (see the relevant section in the AHK help file).

The sleep command may need to be adjusted, or may not be needed at all - I'm just thinking it might not be a bad idea to give the emulator a little time to react to the change to windowed mode before trying to close it.

Also, I'm assuming that you can switch to windowed mode by pressing Alt+Enter which is the usual way.

Let me know if this helps.  :cheers:

Turnarcades

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1973
  • Last login:May 13, 2017, 08:14:29 am
  • Craig @ Turnarcades
    • Turnarcades
Dreamcast emu NullDC problems now sorted!
« Reply #5 on: August 24, 2012, 09:15:27 am »
Well thanks to both you and Badmouth for the suggestions and I did in fact try your suggestion Nitz but came up with a neater one and it's all working smooth! Turns out part of the problem with the errors coming up on exit are to do with the VMU plugins (maple or something like that), which is unfortunate as the problem goes away straight away with the VMU plugins disabled, but you can't save your games d'oh! So for anyone out there having big troubles with Dreamcast, try this setup:

1) Install NullDC and Closemul in the same folder, simply setting key 27 (escape) as the quit key for the emulator.
2) Set up NullDC with the options you want for best performance graphically using the GUI, and set a fixed resolution fullscreen mode (640x480 I use and it's just fine)
3) Disable the second VMU unit on each joypad using the plugins menu (leave the first one in, set the second unit to 'none'). This will reduce crashes anyway by half.
4) Once everything is set up the way you want and tested in fullscreen (from the GUI press ALT+Enter to go fullscreen), get out of the GUI, go into the .cfg file in notepad and set 'launch fullscreen' to 1 and also 'start emulation on startup'. They're not called exactly this but they're similar to this)
5) Once saved, Right-click, go to 'properties' and set the file to be 'read-only'. This is because when it crashes, for some reason the next time the emulator launches it has edited the file to not be fullscreen, which obviously you need, and this negates the need for a hotkey script.
6) Delete the flash bios file in 'data' of the emulator (the readme mentions the exact filename) as for some reason after these changes it will constantly ask you to update the time and date on the Dreamcast every time you launch a game, and may also freeze up. As you've now locked the .cfg file to read-only, it should not ask you for the time and date again and eliminates this freeze possibility.
7) On your desktop, right-click 'my computer', 'properties', 'advanced', 'error reporting', and disable error reporting completely. This will stop the dialogue box popping up that NullDC has crashed each time you exit (which is a problem when you start to launch it from your frontend as you have to click the 'don't send' button each time!)
8) For good measure, go to your start menu, launch services.msc and disable the error reporting service.
9) Set the commandline for your frontend to launch Closemul and it's mapped quit button, then NullDC with the argument to auto-launch the default image followed by "[rom.extension]". I've not tried other rom formats, but if they are .cdi, they will launch fine this way without the annoying addition of virtual drive mounting with Daemontools or similar, speeding up the launch process.

I'm unsure of some of the filenames here or the exact syntax used but will post them if any noobs need them. This method gave the cleanest and fastest launch/quit sequence I could find and now it's all tied perfectly into my frontend. If you already have a working Dreamcast setup and want to try tidying up any workarounds you've got at the moment, try what I've suggested here as I'm sure it will look much cleaner for you!

Thanks for your help in getting this running, it's been bugging me for over a year!