Build Your Own Arcade Controls Forum
Main => Software Forum => Topic started by: markronz on January 07, 2011, 01:06:04 pm
-
Hello everyone-
I use Mala as my front end and am one of the unfortunate few people who suffer from the "loss of focus" problem where upon exiting MAME that Mala is not the application in focus. So you have to left click on Mala to get it back in focus. Yes, I am aware there is a post about this problem in the Mala forum, and I've tried everything in there to no avail. So I've decided to write my own autoit script to simulate a left mouse click after the exit button is pressed. The script is short and sweet, here is the code:
HotKeySet("h", "Actions")
While 1
Sleep(100)
WEnd
Func Actions()
If ProcessExists("Mala.exe") Then
HotKeySet("h")
Send("h")
Sleep(950)
MouseClick("left")
HotKeySet("h", "Actions")
End
EndFunc
The H key is my Exit button in MAME, so that's why H is in the code like that. The ProcessExists check is so that this will only act this way if Mala is running. I just didn't want some strange behavior when doing maintenance every time I typed H.
When I am in Mala this script seems to work fine. The H key is still sent via the Send command, and a left click is simulated. Now my problem is that when I am running MAME and I press my H key to exit, nothing happens. Does anyone know if there's a reason why MAME would not see my Send("h") command? Any ideas?
Thanks!
-
Im an AutoHotkey guy but it seems like your script is capturing the H key so mame never gets it.
AHK will do the same thing but you can specify to let it pass through as well by adding a ~ before the key.
So
h::
Send, Leftclick
would read
~h::
Send, LeftClick
You can try it, they are very similar... Im sure AI will let you do it too. Just not sure the correct usage for AI
-
Hi, thanks for responding. I actually came across this link a few hours ago:
http://www.autoitscript.com/forum/topic/99704-my-script-is-halted-while-mame-is-running/ (http://www.autoitscript.com/forum/topic/99704-my-script-is-halted-while-mame-is-running/)
I don't know if what it says in it is true, but it did sound like someone else was able to get it to work in AHK. So, much like your recommendation, I started to write it in AHK instead. This is what I had come up with:
~h::
Process, Exist, MaLa.exe
If (ErrorLevel != 0) ; If it is not running
{
Sleep, 750
Send {Click}
}
return
What's curious about this is that the above script works on this computer, the one that I wrote it on. Then I compile it in AHK into an EXE. I put this EXE on my arcade machine computer. And it does NOT work on that computer. Well, it half works. For some reason, on my MAME computer, it will recognize that the H key is pressed, and it will do the pause and left click part. But it does not let the letter h pass through. Same script, two computers, and it works on one and only half on the other. Can you think of any reason why that might be? Do you need to have AHK installed on the computer for it to work or something? I do not have AHK installed on the MAME computer, so I am unsure if that has anything to do with it.
Any ideas for me? Appreciate the help!
-
Are you sure the script isnt working.. you can try changing it up a little.
~h::
Process, Exist, notepad.exe
If (ErrorLevel != 0) ; If it is not running
{
Sleep, 750
Msgbox, Notepad is running.
}
return
On second thought you may want to use the "winactivate" to bring mala into focus.
-
Well, I was positive it wasn't working. But I have recompiled it, for what feels like the 100th time, restarted the computer and transferred a new copy over to my MAME pc. Now it works! I have no idea which of those things fixed the issue, but I am not going to think about it any more. It works, and I am happy. At any rate, here is the final version of my AHK code:
#NoTrayIcon
~h::
Process, Exist, MaLa.exe
If (ErrorLevel != 0) ; If it is not running
{
Sleep, 750
Send {Click}
}
return
So anyway, I appreciate the help. If I play around with this method and it gives me problems, I might look into the winactivate command to test out next. Thanks again!