Build Your Own Arcade Controls Forum
Main => Software Forum => Topic started by: spisi on September 15, 2022, 12:50:26 pm
-
So I'm trying to figure a way to limit the number of credits that can used during a single game. I came across Auto Hot Key. This script says: If you hit the 5 or 6 key more than 5 times, the key will then no longer work. When hit Esc key to exit out of the game the script stops. The problem is it doesn't work in MAME. It works for other programs like Excel and Outlook.... In MAME the 5 and 6 keys don't work at all. Any ideas?
key5 := 0
key6 := 0
~esc::
key5 := 0
key6 := 0
return
$5::
key5++
if key5 <= 5
{
send, 5
}
return
$6::
key6++
if key6 <= 5
{
send, 6
}
return
-
I found this thread: http://forum.arcadecontrols.com/index.php?topic=36930.0 but the link is outdated. Does anyone have the coinlimit.exe and .ini?
-
You just need a version of mame that would work with outohotkey and youll be fine.
-
I have tried versions .120, .140, .160, .180, .210, .246 all with the same result.....also tried a few 32 bit with same results
-
OK, after much Googling, I saw that I need to edit the source code... I got pretty far (amazed). I had to edit the input.c file from FORCE_DIRECTINPUT 0 to FORCE_DIRECTINPUT 1. I'm getting stuck compiling....Even if I don't edit the input.c file it doesn't compile. Using version .160 (latest source code with input.c)
-
This is what I get when I try to compile mame .150 (unedited).
-
zanyt13 had a similar problem 10 years ago.
https://www.mameworld.info/ubbthreads/showflat.php?Cat=1&Number=305839&page=&view=&sb=5&o=&vc=1
What path is he talking about? If the path was wrong wouldn't there be a ton more errors?
-
https://hyperspin-fe.com/files/file/11722-mame-174-64bit-nonag-hi-score-forced-directinput/
-
Great thanks Abispac! Their server is down at the moment, I hope it gets back up real soon so I can test it out! :cheers:
-
Still not working....What do I do with the postfx.zip file? I extracted it and get a post.fx file. Do I just leave it in the root directory?
It's behaving the same, the weird thing is the 5 and 6 keys becomes disabled completely.....So the script is half working I guess...maybe my script is bad?
key5 := 0
key6 := 0
~esc::
key5 := 0
key6 := 0
return
$5::
key5++
if key5 <= 5
{
send, 5
}
return
$6::
key6++
if key6 <= 5
{
send, 6
}
return
It can't be a bad script though because it works correctly with notepad. Hmmm..... :banghead:
-
I have managed to get this to work with a few variations.
Using latest Mame on Windows 10 - just the normal Mame download no special build
You need to make a change in mame.ini file
Look for # OSD INPUT OPTIONS
and change
keyboardprovider auto
to
keyboardprovider dinput
Then save and close file
Change the ahk to the one below and it worked for me - so hopefully will work for you as well
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force
key5 := 0
key6 := 0
~esc::
key5 := 0
key6 := 0
return
$5::
key5++
if key5 <= 5
{
Send {5 down}
Sleep, 50
Send {5 up}
}
return
$6::
key6++
if key6 <= 5
{
Send {6 down}
Sleep, 50
Send {6 up}
}
return
-
Eureka!!! That does the trick! Thank you, thank you, thank you Tiberius!!!
Of course there's still another problem now. When using a batch file to run the script and mame simultaneously, mame doesn't find the roms? There's some roms, roms that I don't even have, and none of them work???
ECHO OFF
START "Coinlock.ahk" "C:\Users\John\Desktop\Coinlock.ahk"
START "mame64.exe" "C:\Users\John\Desktop\MAME64a\mame64.exe"
-
I removed the roms folder completely!!! It still shows roms in the list WTH!
-
Mame will show ALL roms it can play whether you have them or not in it's UI unless you are filtering them.
Do you have a complete set of roms that match your mame version or do you just have random roms?
Where are you keeping the roms and have you told Mame the full ROM path in the same in ini file you adjusted earlier?
So a couple of things of things to check out.
But it should work. If mame loads and loads a ROM you know you have adding the ahk to a batch file shouldn't cause any issues.
-
Thanks Tiberius! I got it working, I needed to add this:
pushd "C:\Users\John\Desktop\MAME64a\"
before this:
mame64.exe ssprint
It's working now. But alas I have (I hope) one last problem. How can I tell AHK about a button? I tried mapping my coin1 & coin2 buttons to 5 and 6 respectively in antimicro. But that did not work. I think I need to specify the buttons in the AHK script. Here's my current script:
#SingleInstance Ignore
key5 := 0
key6 := 0
~esc::
key5 := 0
key6 := 0
return
$5::
key5++
if key5 <= 4
{
Send {5 down}
Sleep, 50
Send {5 up}
}
return
$6::
key6++
if key6 <= 4
{
Send {6 down}
Sleep, 50
Send {6 up}
}
return
I added this above it:
Joy17::
{
Send {5 down}
Sleep, 50
Send {5 up}
}
Joy20::
{
Send {6 down}
Sleep, 50
Send {6 up}
}
My coin1 button is button 17 in Windows (U-HID) and coin2 is button 20. I can't get it to work. Any ideas?
-
Just to check, you still have the numbers 5 and 6 registered in Mame as your coin buttons? So you want when you press joystick button 17 or 20 to pretend to be keyboard numbers 5 or 6.
Try changing Joy17 to 1Joy17, that assumes it is the first joystick attached to system, and if that doesn't work keep changing the number one at a time until it does work, then do the same for other button.
You could try the Joystick test script to help figure out joystick number and button number
https://lexikos.github.io/v2/docs/scripts/index.htm#JoystickTest
Scroll down the page a bit and find the correct script for checking joysticks.
Good luck
Ps just checked this on mine and it work
In Mame coin input must be 5 and 6 from keyboard NOT your joystick buttons
Script needs to be as below - but with YOUR joystick button numbers and whatever other changes you want/need to make
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force
key5 := 0
key6 := 0
~esc::
key5 := 0
key6 := 0
return
1joy9::
key5++
if key5 <= 5
{
Send {5 down}
Sleep, 50
Send {5 up}
}
return
7joy9::
key6++
if key6 <= 5
{
Send {6 down}
Sleep, 50
Send {6 up}
}
return
-
Thank you very much Tiberius. I will test out later tonight! :applaud:
-
Did a quick test before I have to leave this morning. I don't think the test is picking up my "joystick". I'm using a U-HID. When I press the buttons nothing happens.
-
My bad....it works! It sees the buttons just as windows does...I must have had something screwy this morning...I was rushing...I love it! Now getting the points banners that show up on the road in Super Sprint actually mean something!!! :laugh2: Thanks again guys Abispac and Tiberius!!!
-
OK one last question I promise.
I want to disable my menu button (Tab) during boot up. So that the kids don't get in there and mess stuff up.
Here's my current script:
#SingleInstance Ignore
Tab := 0
~m:: ;hold m key
Sleep 4000 ;for 4 seconds
send {m up}
Tab := 0
{
MsgBox Menu is now available!
ExitApp
}
return
Tab::
Send {} ;disabled
return
The problem I'm having is that if I press the "m" key and let go, 4 seconds later the message pops up that my menu is available. This is more like "press and wait" I'm looking for "press and hold". How do I tell AHK that I am pressing and holding a key for 4 seconds?
-
The following stops TAB working.
You press and HOLD m for 4 seconds and then you get the pop up box. Once you manually close the pop up box TAB will work again.
If you press m or press and hold m for less than 4 seconds tab still doesn't work but also the letter m DOESN'T work
Tab := 0
m::
{
keywait, m, t4
if errorlevel = 1
{
MsgBox Menu is now available!
ExitApp
}
else
return
}
Tab::return
IF you want m to also be the letter m you need to put ~m ::
-
Great thanks Tiberius!
-
OK, having trouble with this code. I'm attempting to use a button instead of a key on a keyboard.
#SingleInstance Force
Tab := 0 ;disable Tab
2joy12::
{
keywait, 2joy12, t4 ;hold menu button for 4 secs
if errorlevel = 1
{
SoundBeep, 500, 250
ExitApp
}
else
return
}
Tab::return ;tab is back in business
I'm trying to get it to where instead of pressing the menu button (2joy12) to open up the menu, you have to hold it for four seconds, and then it opens the menu.
I have 2joy12 mapped to "Tab" in antimicro. I have Tab set in MAME to "config menu".
-
At the moment your sripts disables Tab from working
After you press and hold joy button 12 for 4 seconds it plays a little noise for 1/4 of a second and then closes the ahk
At this point the Tab button should start working
So I expect the following behaviour at the moment when the ahk is running
Press Tab on keyboard = Nothing happens
Press Joy 12 button = Nothing happens
Press and hold Joy 12 button for less than 4 seconds = Nothing happens
Press and hold Joy 12 for 4 seconds or more = A small sound plays for 1/4 of a second the ahk closes and now Tab and Joy 12 work
Once the ahk closes (ie you have held for more than 4 seconds)
Press Tab on keyboard = Menu opens
Press Joy 12 button = Menu opens
I THINK what you want is (when the ahk is running)
Press Tab on keyboard = Nothing happens
Press Joy 12 button = Nothing happens
Press and hold Joy 12 button for less than 4 seconds = Nothing happens
Press and hold Joy 12 for 4 seconds or more = A small sound plays for 1/4 of a second the menu screen opens
BUT do you now want Tab and Joy Button 12 to work just when pressed or do you want to still have to press and hold Joy 12 for 4 seconds to do anything (eg close menu?)
I think from memory you have to press Tab again to close the menu in Mame?