Build Your Own Arcade Controls Forum

Main => Software Forum => Topic started by: Moksi on November 28, 2017, 12:10:09 pm

Title: AHK for Coin Input
Post by: Moksi on November 28, 2017, 12:10:09 pm
Hello again,

I hope you guys can help me out with putting together a good Ahk for Coin Input.
Im preparing to add a coin mech.
With the X- Arcade only way to a add an extra button is the unused middle mouse button, since i want to credit button hidden example when guests come over

how do i make an ahk   -> exmple  middle mouse button = 5      i want it only active when Hyperspin is enabled so i can use the middle mouse button normally when hyperspin isnt active
Title: Re: AHK for Coin Input
Post by: randjamal on November 28, 2017, 12:54:29 pm
Something like this:

Code: [Select]
#IfWinActive ahk_class hyperspin
MButton::
Send, 5

You'll need to replace "hyperspin" with the ahk_class for the hyperspin program (right click on the ahk tray icon and select "window spy")
Title: Re: AHK for Coin Input
Post by: Moksi on November 28, 2017, 03:04:30 pm
Ok i tried the ahk

#IfWinActive ahk_class ThunderRT6FormDC
MButton::
Send, 5

but it doesnt work yet , what is wrong  windows spy gives me that ahk class
Title: Re: AHK for Coin Input
Post by: randjamal on November 28, 2017, 04:12:45 pm
As a first step can you get it working with Notepad?

i.e.
Code: [Select]
#IfWinActive ahk_class Notepad
MButton::
Send, 5

If this works then you know the issue is with ahk's recognition of Hyperspin. If it doesn't the issue is with something else with your setup.
Title: Re: AHK for Coin Input
Post by: Moksi on November 29, 2017, 04:24:55 am
yes the test ahk works
so like you said the issue is with ahk's recognition of Hyperspin

If the ahk works in Only HyperSpin , will the function middle mouse::5 also work with Mame , Sega Model etc. 
Or will it work with the ahk class from HyperSpin

i typed in the exact ahk_class displayed with Windows Spy, why doesnt it work?
Title: Re: AHK for Coin Input
Post by: Moksi on November 30, 2017, 09:24:40 am
Also just an Ahk with MButton::Send, 5 

doesnt work with hyperspin its like it only works in windows
Title: Re: AHK for Coin Input
Post by: randjamal on November 30, 2017, 04:22:16 pm
Hmm...I don't use Hyperspin, so I can't test, but the next things i would try would be to replace send with one of the other send methods.

Code: [Select]
#IfWinActive ahk_class ThunderRT6FormDC
MButton::
Sendplay, 5
For sendplay to be effective the script needs to be run with administrative rights.

or

Code: [Select]
#IfWinActive ahk_class ThunderRT6FormDC
MButton::
Sendinput, 5
Title: Re: AHK for Coin Input
Post by: DrakeTungsten on November 30, 2017, 10:01:10 pm
I'm not clear what you mean by "work with Hyperspin". It sounds like you are using Hyperspin to run AHK scripts, but you actually want the hotkeys to be in effect when running an emulator launched from Hyperspin, right? More recent versions of MAME don't work with AHK, at least the pre-compiled versions don't. Possibly other emulators don't work with AHK either. If your AHK inside of HS is valid, then the problem is probably the individual emulators' compatability with AHK. I suggest running your AHK scripts and emulators without HS to investigate.

The last I checked, MAME can be compiled in such a way that AHK will work with it. There isn't a direct "work with AHK" flag, but googling MAME and AHK should point you in the right direction.
Title: Re: AHK for Coin Input
Post by: nexusmtz on December 01, 2017, 04:41:42 am
There isn't a direct "work with AHK" flag, but googling MAME and AHK should point you in the right direction.

Keyboardprovider was added around v0173.
If you set keyboardprovider to dinput in mame.ini (or add -keyboardprovider dinput to the command line), code like the following will work:

Code: [Select]
MButton::
ifwinactive ahk_class MAME
{
  sendinput {5 down}
  sleep 30
  sendinput {5 up}
}
return

Note that the sleep delay may have to be adjusted, but 30 works for me.
Title: Re: AHK for Coin Input
Post by: Moksi on December 01, 2017, 06:00:51 am
Yes it probably better to make the ahk work with Mame & the other systems.
I just want to enable the middle mouse button as key 5 when playing those systems , so that when i dont play the mouse button functons normally.

i will try everything out you guys said

WIth mame im using version 0.155

But other option i think which will save me time is buying an i-pac to connect directly to the coin mech

because i have Sega model 2 , supermodel, Sega Ring, Sega Naomi, Taito Type X so then i have to figure out each one to work with ahk if its even possible