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: Emulator Doesn't accept AutoHotKey  (Read 4046 times)

0 Members and 1 Guest are viewing this topic.

EssexMame

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 472
  • Last login:July 22, 2025, 11:52:28 am
  • Mame Weekender
Emulator Doesn't accept AutoHotKey
« on: November 23, 2013, 05:40:47 am »
I am trying to use AutoHotKey to close an emulator (Electrem). The script I have closes notepad but not ElectrEm - either in full screen or window mode.

#IfWinActive, ElectrEm
{
   Escape::sendinput !{F4}
}

In its simplest form -   Escape::sendinput !{F4} - it's still no better

I'm confident the AutoHotKey is working - it closes other programs but the Electrem emulator seems to ignore keystrokes outside of its own. I realise ElectrEm is not a much used emulator here but has anyone experienced this problem with other emulators and if so how did you resolve it?

Currently, its all working EXCEPT that I have to press Alt+F4 to exit. I can map another cabinet key to this,but so much better to map it to esc so that ESC is exit for ALL emulators including Mame.

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9272
  • Last login:Yesterday at 02:05:45 pm
  • ...
RE: Emulator Doesn't accept AutoHotKey
« Reply #1 on: November 23, 2013, 06:36:58 am »
Try
Escape::
Winclose, ElectrEm

That assumes the window name is ElectrEm
If the window title bar name is correct and it still doesn't work, this will kill it.

Escape::
Process, close, ElectrEm.exe

In that one, use the name of the exe.
It's similar to what your script is doing though.
I'm betting that your window name isn't correct, so it's never seeing that window as active.  Run the emulator windowed and see what it says in the title bar.  You script should have that exact name for the window

sent from my phone while driving

EssexMame

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 472
  • Last login:July 22, 2025, 11:52:28 am
  • Mame Weekender
Re: Emulator Doesn't accept AutoHotKey
« Reply #2 on: November 24, 2013, 11:05:16 am »
Magic! That works - thanks BadMouth. It did seem similar but yours works and mine doesn't so great - I'll stick with yours

How would I do similar for keys though. For instance, in a game I'd want to map

Z::{Left}
X::{Right}
Space:: Send 1 ; start game

and so on.

It seems to me the key mappings (such as my mapping of ESCAPE to ALT+F4) don't work as perhaps the emulator overrides them in some way?  Does that make sense?

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9272
  • Last login:Yesterday at 02:05:45 pm
  • ...
Re: Emulator Doesn't accept AutoHotKey
« Reply #3 on: November 24, 2013, 12:11:11 pm »
If the emulator doesn't accept "virtual" key presses, there isn't anything you can do.
The script that is closing it is working outside the emulator.
The emulator isn't getting any input from it.


MAME also doesn't work with virtual key presses (unless you compile you're own with changes), but it does work with virtual joystick input.
If there is an option in the emulator to use a gamepad, you might try using a virtual joystick like vjoy:
http://headsoft.com.au/index.php?category=vjoy


EssexMame

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 472
  • Last login:July 22, 2025, 11:52:28 am
  • Mame Weekender
Re: Emulator Doesn't accept AutoHotKey
« Reply #4 on: November 24, 2013, 02:01:09 pm »
Thanks BadMounth, although doesn't the fact the close script you put in this thread does work with the emulator does work?

I have the SourceCode for Electrem - is the change for Mame (and Mess I assume) to accept virtual keypresses a simple one? I'll perhaps look to see what the code is like and see if I can do something...

I'm using ZX Spectrum in MESS so will have the same problem there. Plenty of Speccy emulators available though so perhaps easier to resolve.

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9272
  • Last login:Yesterday at 02:05:45 pm
  • ...
Re: Emulator Doesn't accept AutoHotKey
« Reply #5 on: November 24, 2013, 02:06:29 pm »
Thanks BadMounth, although doesn't the fact the close script you put in this thread does work with the emulator does work?

No.  The script I posted (or pressing ALT+F4) is like bringing up task manager in windows and forcing the program closed from there.
That is why it works regardless of whether the emulator accepts input from ahk or not.
 ALT+F4 is a windows shortcut that closes the active window, not an input that the emulator is looking for.

Can't help you with modifying the source code, although IIRC it was a simple one line change.
You'll just have to search for the info.

EssexMame

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 472
  • Last login:July 22, 2025, 11:52:28 am
  • Mame Weekender
Re: Emulator Doesn't accept AutoHotKey
« Reply #6 on: November 25, 2013, 07:21:19 am »
It seems I can identify the ElectrEm window using the ahk_class (its SDL_app from AHK's Window Spy). The Title is given as ElectrEm but I can't seem to get that working. no matter, the ahk_class will do fine. So my script is now as follows to map keys for (a lot) of Electron games to the Mame keys. I've tried it here on Windows 7 and it works. the close wasn't working on XP yesterday but I'll give it another go now I know this script is working here. Also need to try it with a game loaded/running.

;ElectrEm to Mame Keys
#IfWinActive ahk_class SDL_app ;ElectrEm from AHK Windows Spy
{
   up::'
   down::/
   left::z
   right::x      
   1::space                           ;Start Game (start player 1) assuming it is Space
   2::send DG{return}         ;For Highscore Entry (press Start player 2).
   Escape::WinClose, ElectrEm    ;Exit Electrem
}
return

EssexMame

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 472
  • Last login:July 22, 2025, 11:52:28 am
  • Mame Weekender
Re: Emulator Doesn't accept AutoHotKey
« Reply #7 on: November 26, 2013, 05:54:40 am »
That now working great - thanks to all!

One thing still though - I want to have a key (such as Player 1, 6th fire button =x) to map to an entry followed by Enter on the highscore table

so,
x::send EssexMame {Enter}

However, though that works in notepad I can't seem to get it working here despite all other keys working. Is the command to send a string and "Enter" correct?

empardopo

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 526
  • Last login:July 20, 2025, 05:12:51 am
    • My personal forum
Re: Emulator Doesn't accept AutoHotKey
« Reply #8 on: November 28, 2013, 05:57:53 am »
Do you know AllInOneFYC?  ;D