Sending commands to MAME

Ask gaming related questions (AHK v1.1 and older)
DJQuad
Posts: 26
Joined: 25 Mar 2016, 10:11

Sending commands to MAME

18 May 2017, 18:15

Hey all, I've seen a few threads about sending commands to MAME but nothing resolved. Does anyone know why this doesn't work?

Code: Select all

SendMode Input
setKeyDelay, 50, 50
autofire:=0

]::
	autofire:=!autofire
	
	while (autofire=1)
	{
		Send, {Ctrl}
		sleep, 100
	}
return
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Sending commands to MAME

19 May 2017, 03:21

"doesn't work" is a very broad term, and the title of the post does not help one work out what exactly your problem is.
What about it doesn't work?
Does AHK ever work with MAME, or is it just this script.

Probably, your problem is this:

Code: Select all

SendMode Input
setKeyDelay, 50, 50
SendMode Input makes Send synonymous with SendInput, which ignores SetKeyDelay, which you probably need to make keys held for 50ms, so MAME will recognize them.
Remove the line SendMode Input, I see no point in using SendInput for MAME
DJQuad
Posts: 26
Joined: 25 Mar 2016, 10:11

Re: Sending commands to MAME

19 May 2017, 13:27

I removed the first line but it didn't help. I can't get any script working in MAME per the other couple threads I searched for.
DJQuad
Posts: 26
Joined: 25 Mar 2016, 10:11

Re: Sending commands to MAME

17 Jun 2017, 14:50

This doesn't work either :(

Code: Select all

toggle = 0
#MaxThreadsPerHotkey 2

]::
    Toggle := !Toggle
     While Toggle{
        ControlSend, , {LControl down}{LControl up}
        sleep 100
    }
return
TygerByte
Posts: 96
Joined: 12 Aug 2016, 05:22

Re: Sending commands to MAME

17 Jun 2017, 15:06

Give it a shot and if something works pull out the working bit from the source https://autohotkey.com/board/topic/95653--/
DJQuad
Posts: 26
Joined: 25 Mar 2016, 10:11

Re: Sending commands to MAME

17 Jun 2017, 16:15

Yeah I tried that before but when I hit space after making the game window active nothing happens.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Sending commands to MAME

18 Jun 2017, 07:41

Maybe you are sending keys too fast.
Many games do not like keys going up and down multiple times a "frame".
Seeing as this is emulators (ie old games), then it is likely that their tick rate is quite slow.
DJQuad
Posts: 26
Joined: 25 Mar 2016, 10:11

Re: Sending commands to MAME

18 Jun 2017, 11:34

No go :(

Code: Select all

toggle = 0
#MaxThreadsPerHotkey 2

]::
    Toggle := !Toggle
     While Toggle{
        ControlSend, , {LControl down}sleep 500{LControl up}sleep 500
    }
return
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Sending commands to MAME

18 Jun 2017, 11:37

Code: Select all

     While Toggle{
        ControlSend, , {LControl down}sleep 500{LControl up}sleep 500
    }
I don't think you can put sleeps in send commands like that. I think you are just typing the text "Sleep 500".
Just put a SetKeyDelay, 500, 500 at the start of the script and Send {LCtrl}
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Sending commands to MAME

18 Jun 2017, 11:40

Also, ControlSend, , {LControl down} is not targetting a window (Missing window title param).
Just try getting it to work with regular send first - ControlSend is only really for when you need to send to an inactive window
DJQuad
Posts: 26
Joined: 25 Mar 2016, 10:11

Re: Sending commands to MAME

25 Jun 2017, 10:39

Nope! :(

Code: Select all

SetKeyDelay, 500, 500
toggle = 0
#MaxThreadsPerHotkey 2

]::
    Toggle := !Toggle
     While Toggle{
        Send {LCtrl}
    }
return
DJQuad
Posts: 26
Joined: 25 Mar 2016, 10:11

Re: Sending commands to MAME

03 Jul 2017, 10:48

Does anyone have any other ideas to try?
Noesis
Posts: 301
Joined: 26 Apr 2014, 07:57

Re: Sending commands to MAME

04 Jul 2017, 05:12

One thing I noticed you haven't tried is forcefully do your own Setkeydelay in combination with send mode input. Reason being setkeydelay is ignored by Input send mode but sometimes SendInput is the only mode of send that will work with a program. So try something like:

Code: Select all

SendMode, Input
toggle = 0
#MaxThreadsPerHotkey 2

]::
    Toggle := !Toggle
     While Toggle{
        Send {LCtrl Down}
        Sleep, 500		; this is the press duration part of Setkeydelay.
        Send {LCtrl Up}
        Sleep, 500		; this is kind of the delay aspect of Setkeydelay (it would work more like it at the top of the loop, but I prefer instant start on the first press) 
    }
return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 45 guests