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: PC Script Coding HELP!  (Read 2166 times)

0 Members and 1 Guest are viewing this topic.

JudgeRob

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 468
  • Last login:March 05, 2024, 10:55:50 pm
    • forum.arcadecontrols.com/index.php/topic,149265.120.html
PC Script Coding HELP!
« on: June 28, 2017, 11:56:58 pm »
Hi,

I am desperately looking for some help with a script/code for calling a button press in Windows 7.  All I need is something I can put in a .bat file and call up.  Basically, I am trying to call up a button press to exit MAME.  My exit button is set to the keystoke "b".  So, I would REALLY like to be able to .bat script this button press for "b".  Right now I have a work around where a relay "physically" presses an input on an ipac controller, but I don't like this setup.  It involves too many extra circuits and variables to fail.  And... it actually is failing at times, so I would really like to accomplish this via code if possible. 

I researched my brains out on this and failed.  If anyone can help me figure this out I will be your best friend. 

05SRT4

  • Trade Count: (+5)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1092
  • Last login:June 02, 2024, 04:10:04 pm
  • Check out my Pow Pow
Re: PC Script Coding HELP!
« Reply #1 on: June 29, 2017, 12:38:15 am »
Cant you just make a Shift Function on the Ipac to press b ?
So pressing two buttons on your control panel will exit.

https://www.ultimarc.com/ipac2.html

Talks more about it.

Titchgamer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4222
  • Last login:December 17, 2023, 08:05:48 am
  • I have a gaming addiction.....
Re: PC Script Coding HELP!
« Reply #2 on: June 29, 2017, 01:54:36 am »
Cant you just make a Shift Function on the Ipac to press b ?
So pressing two buttons on your control panel will exit.

https://www.ultimarc.com/ipac2.html

Talks more about it.

This ^

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9226
  • Last login:Yesterday at 09:41:59 am
  • ...
Re: PC Script Coding HELP!
« Reply #3 on: June 29, 2017, 07:22:25 am »
Autohotkey works great for this type of stuff, but the problem is that MAME uses raw input from the keyboard so doesn't respond to fake key presses generated by programs.

The workaround is to change a line of code in mame and compile it so it accepts the fake input, or have autohotkey send fake gamepad presses which MAME does accept.

Both add a layer of complication to what would otherwise be a super simple autohotkey script.

JudgeRob

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 468
  • Last login:March 05, 2024, 10:55:50 pm
    • forum.arcadecontrols.com/index.php/topic,149265.120.html
Re: PC Script Coding HELP!
« Reply #4 on: June 29, 2017, 12:55:31 pm »
Quote
Cant you just make a Shift Function on the Ipac to press b ?

Yes, I already have this set up.  I have a special "front-end" project I am incorporating that does not use any button presses.  The games are called up with a RFID token instead.  But I am trying to have the code exit out of MAME before re-launching the next game.  I've had success with a prototype relay circuit, but if there were a simple set code to call up, I could eliminate some weight and points of hardware failure.

Quote
the problem is that MAME uses raw input from the keyboard so doesn't respond to fake key presses generated by programs

Damn it, I was afraid of that.  Thanks for the knowledge.  I guess I will have to stick with using a relay to automatically "click" the input.  I can't think of any other automated ways to exit from MAME.  Unless anyone has any creative ideas?

« Last Edit: June 29, 2017, 12:57:06 pm by JudgeRob »

melvinbates

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 106
  • Last login:April 26, 2023, 11:39:02 am
  • Another day in paradise
Re: PC Script Coding HELP!
« Reply #5 on: June 29, 2017, 01:06:11 pm »
If you're not concerned with killing it nicely, you could run this in a bat file. 

taskkill /im mame.exe /f

That will stop it forcefully.

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9226
  • Last login:Yesterday at 09:41:59 am
  • ...
Re: PC Script Coding HELP!
« Reply #6 on: June 29, 2017, 01:54:27 pm »
My knowledge might be outdated, but I believe MAME only uses raw mouse data if multimouse is enabled.
So a fake mouse click from autohotkey might work if multimouse is not enabled in mame.ini

https://www.autohotkey.com/

The autohotkey script would be as simple as
Code: [Select]
MouseClick, middlehttps://autohotkey.com/docs/commands/MouseClick.htm
Then just map the exit key in MAME to the middle mouse button.

If you "compile" the autohotkey script (which is as simple as right clicking and selecting compile), then it will even run on a PC that doesn't have autohotkey installed.
Again, it's been years since I messed with this stuff, so I am assuming it still works on modern versions of Windows.
« Last Edit: June 29, 2017, 02:01:36 pm by BadMouth »

JudgeRob

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 468
  • Last login:March 05, 2024, 10:55:50 pm
    • forum.arcadecontrols.com/index.php/topic,149265.120.html
Re: PC Script Coding HELP!
« Reply #7 on: June 29, 2017, 09:04:32 pm »
Thanks, two great ideas!  I shall try them both and report back.   :applaud:

What kind of bad stuff can happen by forcing MAME closed with taskkill?

JudgeRob

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 468
  • Last login:March 05, 2024, 10:55:50 pm
    • forum.arcadecontrols.com/index.php/topic,149265.120.html
Re: PC Script Coding HELP!
« Reply #8 on: June 30, 2017, 12:58:55 am »
I've tried using AutoHotKey.  I can't quite tell if it will work yet.  Seems like when I call up the executable, it is switching the active window away from MAME... I'll try to see how AutoHotKey can select the active window.  I have to say, it is a nifty little programming environment!

JudgeRob

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 468
  • Last login:March 05, 2024, 10:55:50 pm
    • forum.arcadecontrols.com/index.php/topic,149265.120.html
Re: PC Script Coding HELP!
« Reply #9 on: June 30, 2017, 10:46:36 pm »
I've run some tests and, so far, MAME does not appear to respond to simulated mouse buttons either.  :-[

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9226
  • Last login:Yesterday at 09:41:59 am
  • ...
Re: PC Script Coding HELP!
« Reply #10 on: June 30, 2017, 11:09:04 pm »
Well, if you want to try your hand at compiling MAME for yourself it looks like Headkaze's compiling tool now has a simple check box to force direct input.  I'm pretty sure that was the option to enable fake key presses.

http://www.headsoft.com.au/index.php?category=mame&page=mc64

or

This guy made a tool, but I can't say if it works:
http://forum.arcadecontrols.com/index.php/topic,141243.msg1461776.html#msg1461776

or

i just google the keywords mameui64 [release number] dinput nonag and there plenty of places that have them precompiled.

Keep in mind that this disables raw data, so things like multiple mice (or light guns that show up as mice) will not work.
Also the no-nag disables MAME messages that tell you the game doesn't work, so don't go asking why a game isn't working until checking it with the normal version of MAME.  ;D

« Last Edit: June 30, 2017, 11:11:47 pm by BadMouth »

JudgeRob

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 468
  • Last login:March 05, 2024, 10:55:50 pm
    • forum.arcadecontrols.com/index.php/topic,149265.120.html
Re: PC Script Coding HELP!
« Reply #11 on: July 02, 2017, 09:18:45 pm »
Thanks for the info.   Hmm, I've been using MAME .167 +nonag +hiscore +directinput without success.  Is there some way to verify if the direct input is actually being forced?  Maybe I'll try another version... ?

JudgeRob

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 468
  • Last login:March 05, 2024, 10:55:50 pm
    • forum.arcadecontrols.com/index.php/topic,149265.120.html
Re: PC Script Coding HELP!
« Reply #12 on: July 03, 2017, 08:22:01 pm »
Brilliant, thanks mate!  I tried this tool and it worked:
Quote
This guy made a tool, but I can't say if it works:
http://forum.arcadecontrols.com/index.php/topic,141243.msg1461776.html#msg1461776

I feel like re-compiling is the "right" way to do it, but hopefully with this patch I won't have to re-configure my setup all over again.  Seems to work well so far, but I still have to test it with all the games.  No problems with DigDug and Donkey Kong. 

Thanks a ton BadMouth.  Your knowledge on this stuff is incredible.  Thanks to you I can avoid ripping out my RFID reader and rebuilding a relay circuit.  And... less mechanics to fail and a couple fewer wires running around!  Stoked!   ;D  :cheers: