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: Pre command & post command  (Read 11967 times)

0 Members and 1 Guest are viewing this topic.

PaTrYcK

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 150
  • Last login:May 02, 2020, 05:22:19 am
Pre command & post command
« on: July 11, 2012, 07:11:22 am »
Hi, i have one problem with epsxe emulator because when i press alt sx button the games is blocked...

I resolved it with my autohotkey script, but how i can configure mala to start this exe when i launch epsxe emulator?
How i can close it when i close the epsxe emulator?

Thanks

Treco

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 7
  • Last login:July 13, 2015, 08:11:42 pm
Re: Pre command & post command
« Reply #1 on: July 20, 2012, 10:41:31 am »
I like your idea, but i'm not MALA developer, in addition to your ideia it will nice to see:
On MALA start execute command
On emulator start execute command
On game start execute command
On game vertical start execute command
On game horizontal start execute command
On game horizontal end execute command
On game vertical start execute command
On game end execute command
On emulator end execute command
On MALA end execute command

Thankyou

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Pre command & post command
« Reply #2 on: August 25, 2012, 05:44:37 pm »
@treco

All these things are possible already by using the Mala API. Granted, it's not settings and batch files, but the ability is there.

@patryck
The best way to set that up is to configure mala to run your AHK Script or a bat file, etc.

Then, in the script/bat file
1) execute whatever startup you need
2) start your emulator with the proper command line args and wait for it to close
3) when the emu closes, run any shutdown code you need and exit the script.

PaTrYcK

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 150
  • Last login:May 02, 2020, 05:22:19 am
Re: Pre command & post command
« Reply #3 on: September 05, 2012, 08:21:19 am »
Hi drventure , thanks for your reply!


Then, in the script/bat file
1) execute whatever startup you need
2) start your emulator with the proper command line args and wait for it to close
3) when the emu closes, run any shutdown code you need and exit the script.

I have the autokey script in c:/mala/script.exe

I need your help...which is the command for start this autokey with emulator?

Thanks!

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Pre command & post command
« Reply #4 on: September 06, 2012, 09:47:09 am »
What I do is configure MALA to execute a BAT file instead of MAME directly, in MALA's config screen.

Then, in that BAT file, you can do whatever you need to do. Mala will pass you the mame rom name of the rom that it's trying to start. It's up to you to actually start MAME with that roms name, something like this

Code: [Select]
cd c:\mame
start "Mame" /WAIT Mame.exe %1

You'll want to use the START command so that the bat file waits till Mame exits before it continues.
For details on START see
http://www.computerhope.com/starthlp.htm

Finally, since you've now got a BAT file sitting between Mala and Mame, you can run whatever you want BEFORE and AFTER you run mame.

So an AHK script could be run like:

c:\autohotkey\AutoHotKey.exe MyScript.ahk

Here's some info on running AHK from the command line (or a BAT file)

http://www.autohotkey.com/docs/Scripts.htm#cmd

Gray_Area

  • -Banned-
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3363
  • Last login:June 23, 2013, 06:52:30 pm
  • -Banned-
Re: Pre command & post command
« Reply #5 on: September 06, 2012, 10:42:47 pm »
I'm trying to remember what I wanted to do in this vein.........I think it was only to ensure there was no flash back to the game list between the game loading screen and the game loading (for example with VP and AAE).
-Banned-

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Pre command & post command
« Reply #6 on: September 06, 2012, 11:41:31 pm »
I know what you mean. I believe that flash is because Mala is throwing up the Loading screen, then launching, then taking down the loading screen after a few seconds.

If it takes longer than that timeout to load the game, you get what looks like that flash.

Really mala ought to just leave the loading screen up much longer, but, I can see the opposite problem, too.

If it's up too long, you could quit the game only to see a flash of "loading" and then back to Mala, which would likely also be objectionable.

Gray_Area

  • -Banned-
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3363
  • Last login:June 23, 2013, 06:52:30 pm
  • -Banned-
Re: Pre command & post command
« Reply #7 on: September 09, 2012, 03:18:30 pm »
I know what you mean. I believe that flash is because Mala is throwing up the Loading screen, then launching, then taking down the loading screen after a few seconds.

If it takes longer than that timeout to load the game, you get what looks like that flash.

Really mala ought to just leave the loading screen up much longer, but, I can see the opposite problem, too.

If it's up too long, you could quit the game only to see a flash of "loading" and then back to Mala, which would likely also be objectionable.

Welp....not even every quick-loading game in MAME takes the same time to load, and Mala catches it right, which suggests to me that Mala knows when the game is not only loading but also displaying. I assumed this would be the case for any game, any emulator - unless there was some thing that told Mala differently...or Mala was mis-intepreting some thing during loading sequence.

For example, AAE through the command line is almost instant. But through Mala, it's different: loading screen, then pop back to layout with an apparently minimized black screen (I'm thinking Mala is having trouble with the OpenGL transition or something), sits there for five to ten seconds, and finally the game loads.

With Visual Pinball I think it's not Mala's fault, as VP has those damn splash screen. Even Howard's wrapper can't totally negate them.
-Banned-

empardopo

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 526
  • Last login:Today at 01:05:44 pm
    • My personal forum
Pre command & post command
« Reply #8 on: September 09, 2012, 03:56:57 pm »
You could take a look to AllInOne.
Greetings!

PaTrYcK

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 150
  • Last login:May 02, 2020, 05:22:19 am
Re: Pre command & post command
« Reply #9 on: September 16, 2012, 04:39:00 am »
@drventure
thanks for your reply...

I would like to start the autohotkey file only when I start the emulator epsxe and I would like it closed automatically when I close epsxe, i can do it directly here?


drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Pre command & post command
« Reply #10 on: September 17, 2012, 08:37:52 am »
Haven't used those options, but that would sure seem like the appropriate way to do it.

The only thing you might run into is what is considered the "current" directory. I'm guessing the ROM folder, but it could be the MALA folder, or the EMU folder. You could test it by using

DIR
PAUSE

If you always reference full paths, though, there shouldn't be any issue.

PaTrYcK

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 150
  • Last login:May 02, 2020, 05:22:19 am
Re: Pre command & post command
« Reply #11 on: September 17, 2012, 05:33:12 pm »
Hi drventure, thanks!

The name of my autohotkey file is "script.exe" and directory of this file is: c:/script.exe.

I tryed this configuration, i see that script is started, but Mala not launch the epsxe emulator, while if i closed the script mala work perfectly and epsx started...


drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Pre command & post command
« Reply #12 on: September 17, 2012, 05:49:19 pm »
I haven't tested this part of Mala out a lot yet (I plan on it with Virtual Pinball etc).

One thing that might be causing issues is you need to use the backslash in your paths

c:\script.exe

Another is how script.exe works. Mala, +I THINK+ will execute each of the pre and post commands, waiting for each to finish before moving on.

In this case you don't want that.

You may need to use a command line like start or cmd

as in

cmd /k c:\script.exe

or

start "Title" c:\script.exe

Alternately, get rid of the pre and post commands, and for the emulator, instead of specifying espx directly, set a BAT file in that field, then create a BAT file that executes your pre and post commands around starting the emulator.

Gray_Area

  • -Banned-
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3363
  • Last login:June 23, 2013, 06:52:30 pm
  • -Banned-
Re: Pre command & post command
« Reply #13 on: September 18, 2012, 03:22:43 pm »
Same issue I had. It would not continue to game load.
-Banned-

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Pre command & post command
« Reply #14 on: September 18, 2012, 04:15:38 pm »
Just had a sec to try this out.

If you want to use the Pre and post commands for ANYTHING that "stays loaded", you'll need to use something like this for your command line

cmd /c start "" yourapphere.exe

so, for instance, i tried notepad.exe

Using this:

notepad.exe

for a "pre command" did exactly what you guys see, it stops at notepad, as soon as I close notepad, the emulator would start up.

So,I changed the command line to

cmd /c start "" notepad.exe

and that works perfect. Notepad starts in the background and the emulator is then loaded.

Same this with post commands.

Basically, mala is waiting for your command to exit.

The only way to make that happen is to use CMD /C Start, in order to fire up the "actual" command separately, so that the cmd shell can exit and make mala happy.


PaTrYcK

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 150
  • Last login:May 02, 2020, 05:22:19 am
Re: Pre command & post command
« Reply #15 on: September 20, 2012, 05:25:00 pm »
WOW, now work fine, thanks!

I use your cmd: cmd /c start "" script.exe and i put file script.exe in to "windows" folder, my autohotkey script.exe start with emu, perfect!

So, you can help me for close it when i closed the emu?

Thanks ;)


 :applaud:

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Pre command & post command
« Reply #16 on: September 20, 2012, 05:54:46 pm »
Glad that's working.

About stopping the script. Wow, I didn't think it'd be particularly tough, but looks like I was wrong.

I don't see any obvious command line switch to do it.

I did turn up this

http://www.autohotkey.com/docs/commands/OnMessage.htm

Basically, you have your actual script, which will terminate on receipt of a specific message.

Then you write ANOTHER script to send that message.

Then, you execute the second script at the end of the run (after the emu has closed), it sends a message to the already running first script, which then shuts down, then the second script automatically closes.

Sorry, though, don't have any examples of that. The link above looks like it has some good stuff on it though.

PaTrYcK

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 150
  • Last login:May 02, 2020, 05:22:19 am
Re: Pre command & post command
« Reply #17 on: September 20, 2012, 06:48:06 pm »
Hi, i have found the way for close the script, in the post-command i have used:

taskkill /im script.exe

and when i close the emulator the script is killed ;)

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Pre command & post command
« Reply #18 on: September 20, 2012, 06:49:18 pm »
I keep forgetting about taskkill.

Good call!

PaTrYcK

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 150
  • Last login:May 02, 2020, 05:22:19 am
Re: Pre command & post command
« Reply #19 on: September 20, 2012, 06:51:21 pm »
Thanks for your support  :cheers:

Gray_Area

  • -Banned-
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3363
  • Last login:June 23, 2013, 06:52:30 pm
  • -Banned-
Re: Pre command & post command
« Reply #20 on: September 21, 2012, 05:02:00 pm »
Obviously Mala was waiting for the app to close, and I knew it would be something simple to have it run in the background. I just don't know command line beyond running an app and navigating directories. I still can't remember what I wanted this for, though, so.....
-Banned-

Gray_Area

  • -Banned-
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3363
  • Last login:June 23, 2013, 06:52:30 pm
  • -Banned-
Re: Pre command & post command
« Reply #21 on: September 22, 2012, 04:15:18 pm »
Oh, it was in my bookmarks:


Quote
I have gamepad controllers in one rig, and shelling to Mala means joytokey can't load.

So I thought I'd load joytokey via emulator pre-command. I assumed the pre-command syntax would be "dir>joytokey.exe, and joytokey does load. However, the game doesn't load/Mala sticks on the loading screen. Exiting/canceling joytokey allows Mala to continue and load the game.

What does the syntax need to be?....or is this avenue not viable within Mala?

http://forum.arcadecontrols.com/index.php/topic,115347.0.html


So similar deal as above. I don't recall whether I found a way to shell to Mala; or I hid the task bar, set a game-type image for the background, and put Mala and joytokey in the start folder. But I'll keep this in mind if I go back to it.


By the way, I'm not seeing the difference in your cmdline entries:


Quote
cmd /c start "" yourapphere.exe

so, for instance, i tried notepad.exe

Using this:

notepad.exe

for a "pre command" did exactly what you guys see, it stops at notepad, as soon as I close notepad, the emulator would start up.

So,I changed the command line to

cmd /c start "" notepad.exe
« Last Edit: September 22, 2012, 04:18:23 pm by Gray_Area »
-Banned-

Wade007

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 309
  • Last login:April 06, 2017, 01:33:35 pm
  • A MAME cabinet at home is heaven
    • bit.ly/1cWnoIC
    • Cheapskategamer.com
Re: Pre command & post command
« Reply #22 on: January 28, 2013, 09:14:22 pm »
I know this thread is a bit old, but I have similar problem and seem to be very close to solving it given the info in this thread regarding the Pre/Post commands in Mala.

I'm running Visual Pinball with Mala. I'm using Howard_Casto's Visual Pinball wrapper to launch the tables from Mala. Everything works great except that I want to run an Auto Hot Key script ALSO so I can remap the mouse buttons and also create a two-button ESC combo. This is to make sure everything runs smoothly on my X-Arcade tankstick.

So... what I'm trying to do is run an AHK exe (VPTable-Launch.exe) in the Pre-Command that will remap the keys, then launch the VP wrapper (vp-launcher.exe) with the keys still remapped and then exit the wrapper with my chosen two-button exit mapped to ESC, close the AHK script, then jump back to Mala.

The problem is that Mala opens the AHK script but will hang. the controls for VP won't work (flippers, etc). I have to quit the script and then Visual Pinball will work. I want them both to run simultaneously. Is that possible?

My script looks like this:

______________________

LButton::D
RButton::G

~2 & ~4::
Send {ESC}

Exit APP
return

______________________

Precommand:
cmd /c start "" "C:\Arcade\Visual Pinball\VPTable-Launch.exe"

Postcommand:
tskill VPTable-Launch.exe


All other set-up coding is the same as before, pointing to Howard_Casto's "vp-launch6.exe" wrapper.


Do I need some sort of loop command?:
http://forum.arcadecontrols.com/index.php/topic,89321.msg937485.html#msg937485

How can I get the AHK scripting to work alongside the vp-launch6.exe wrapper??? This is so frustrating? Any help?  :badmood:
My Super Arcade cabinet project:
Software blog article: http://bit.ly/1cWnoIC

Hardware blog article: http://bit.ly/1dWxjvP

YouTube video: http://bit.ly/1N818Xm

Super Arcade Cabinet Progress thread (Now Complete):
http://forum.arcadecontrols.com/index.php/topic,123292.0.html

Frontend Video Intro: http://bit.ly/1P9HPDN

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Pre command & post command
« Reply #23 on: January 29, 2013, 08:34:48 am »
I would have thought that would work. I'll see if I can replicate that prob.
« Last Edit: January 29, 2013, 08:36:51 am by drventure »

Wade007

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 309
  • Last login:April 06, 2017, 01:33:35 pm
  • A MAME cabinet at home is heaven
    • bit.ly/1cWnoIC
    • Cheapskategamer.com
Re: Pre command & post command
« Reply #24 on: January 29, 2013, 12:36:12 pm »
drventure,
Thanks for your help. I can sense I'm close to getting this to work, but I just can't figure out what I'm doing wrong.

It's odd. I've been able to get the AHK script to work by itself AND launch Visual Pinball, but the normal controls don't work, meaning Mala is limiting Howard's wrapper or VP from working fully because it's hung up on the AHK script. If I quit the script, then VP works normally. When I close VP (using ESC rather than my two-button combo set up by the AHK script), I get the error that it couldn't close the script. I'm sure this end error is because I had to close it in order to play VP.

 
My Super Arcade cabinet project:
Software blog article: http://bit.ly/1cWnoIC

Hardware blog article: http://bit.ly/1dWxjvP

YouTube video: http://bit.ly/1N818Xm

Super Arcade Cabinet Progress thread (Now Complete):
http://forum.arcadecontrols.com/index.php/topic,123292.0.html

Frontend Video Intro: http://bit.ly/1P9HPDN

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Pre command & post command
« Reply #25 on: January 29, 2013, 02:37:13 pm »
One possibility is to not use the pre/post command, and setup a BAT file that accepts the arguments that Mala supplies, and launches AHK, then VP, waits for VP to finish, then closes out AHK.

Here's an example I use for launching DukeNukem 3D, and turning on LEDBlinky to run sound animations, then turning it off when done

REM Run Duke Nukem3d
c:
cd C:\Games\EDuke3D
REM Start Audio Animation
REM "\\arqadium\drivec\Games\FrontEnds\Mala\Plugins\LEDBlinky\LEDBlinky.exe" audio.lwax pattern01.lwax
start "" /wait eduke32.exe
REM Stop Animation
REM "\\arqadium\drivec\Games\FrontEnds\Mala\Plugins\LEDBlinky\LEDBlinky.exe" 11


note the START ....  /wait

that stops the bat file from continuing till the user exits dukenukem.

Of course, you'll need to experiment with the %1 %2 %3 arguments that mala passes to the bat file to have it load up the selected table when launching VP, but that's pretty straightforward.

Wade007

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 309
  • Last login:April 06, 2017, 01:33:35 pm
  • A MAME cabinet at home is heaven
    • bit.ly/1cWnoIC
    • Cheapskategamer.com
Re: Pre command & post command
« Reply #26 on: January 29, 2013, 03:42:19 pm »
Thanks for the suggestion. You may be onto something with the BAT file idea. I can see the logic where you state "setup a BAT file that accepts the arguments that Mala supplies, and launches AHK, then VP, waits for VP to finish, then closes out AHK."

I've messed with BAT files a little bit but am no expert.
What does "REM" mean? Just a remark? Ignored line of code?

How would I allow Mala to pass the %1% variable (name of table) through the BAT file and onto the final VP wrapper (vp-launch6.exe)? I've never done that before.
« Last Edit: February 01, 2013, 03:25:08 am by Wade007 »
My Super Arcade cabinet project:
Software blog article: http://bit.ly/1cWnoIC

Hardware blog article: http://bit.ly/1dWxjvP

YouTube video: http://bit.ly/1N818Xm

Super Arcade Cabinet Progress thread (Now Complete):
http://forum.arcadecontrols.com/index.php/topic,123292.0.html

Frontend Video Intro: http://bit.ly/1P9HPDN

Wade007

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 309
  • Last login:April 06, 2017, 01:33:35 pm
  • A MAME cabinet at home is heaven
    • bit.ly/1cWnoIC
    • Cheapskategamer.com
Re: Pre command & post command
« Reply #27 on: January 30, 2013, 10:51:58 pm »
Couldn't I simply launch a BAT file in the Pre-Command that would run an AHK script in the background to set up a few controls, then have Mala launch the wrapper (vp-launch6.exe) normally using the command line, then have a BAT file in the Post Command close the AHK script.

Couldn't that work?

Any idea what that batch file might look like?
My Super Arcade cabinet project:
Software blog article: http://bit.ly/1cWnoIC

Hardware blog article: http://bit.ly/1dWxjvP

YouTube video: http://bit.ly/1N818Xm

Super Arcade Cabinet Progress thread (Now Complete):
http://forum.arcadecontrols.com/index.php/topic,123292.0.html

Frontend Video Intro: http://bit.ly/1P9HPDN

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Pre command & post command
« Reply #28 on: January 30, 2013, 11:10:49 pm »
You're right about the REM lines, those are just remarks or comments.

And yes, starting AHK with the precommand, then terminating it with the post command should work.

If I can get some time tomorrow, I'll see if I can put together an example for you.

Wade007

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 309
  • Last login:April 06, 2017, 01:33:35 pm
  • A MAME cabinet at home is heaven
    • bit.ly/1cWnoIC
    • Cheapskategamer.com
Re: Pre command & post command
« Reply #29 on: January 31, 2013, 11:02:02 am »
OK, I've done some experimenting and I've had more success!

I created an AHK file called "VPControls.ahk" which ONLY sets up the controls I need:

_________________________________

Set WorkingDir, C:\Arcade\Visual Pinball\
#SingleInstanceforce

LButton:: g
RButton:: d

~2 & ~4::
Send {ESC}; Note no ExitAPP, Return after this line to keep the script running.

_________________________________

Then in Mala put the following under the Execution tab...

Precommand:
cmd /c start "" "C:\Arcade\Visual Pinball\VPControls.ahk

Command line (same as always):
"%rom%.%ext%"

Postcommand:
taskkill VPControls.ahk


Everything under the Basics tab stayed the same as always...

Executable (keeping the wrapper as the launcher):
C:\Arcade\Visual Pinball\vp-launch6.exe

Rom Path
C:\Arcade\Visual Pinball\Tables

Rom Extensions:
vpt

_________________________________


And it works for the most part!

Two minor problems:

The "taskkill" command line doesn't seem to work. It doesn't give me an error but AutoHotKey.exe is still running in the background when I go back to the Mala menu and the script controls are still running. How to end the script for good after vp-launch6.exe quits? Run the script as an .exe. Go back to the BAT file idea to open and close the AHK scripts?

The other issue is that when a VP table is open the 2+4 combo exit key sends ESC but not the way I intended. Visual Pinball picks it up and I get the close menu. What I want is the outright automatic Quit/Close I get when I manually press ESC. This is what the vp-launch6.exe does but for some reason even though it's running fine, my 2+4 key acts as if VP was running alone. Any ideas on how to trully send the escape key. Perhaps a AHK code like {Down ESC} or something?

So it looks like I'm about 90% there. Very close. Any ideas on the last two issues?
My Super Arcade cabinet project:
Software blog article: http://bit.ly/1cWnoIC

Hardware blog article: http://bit.ly/1dWxjvP

YouTube video: http://bit.ly/1N818Xm

Super Arcade Cabinet Progress thread (Now Complete):
http://forum.arcadecontrols.com/index.php/topic,123292.0.html

Frontend Video Intro: http://bit.ly/1P9HPDN

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9269
  • Last login:Today at 10:29:05 am
  • ...
Re: Pre command & post command
« Reply #30 on: January 31, 2013, 11:58:26 am »
No reason to set working directory in the script since all it is doing is remapping buttons.

Code: [Select]
~2 & ~4::
Process, Close, vp-launch6.exe

Will kill visual pinball
You might have to swap in the actual visual pinball exe in place of the wrapper.
Like I said, I'm not running VP.

That just leaves exiting the script.
You could have it check to see if a virtual pinball windows exists. (ifwinexist)
If it does, it will return.  If not, it will exit.
I don't remember the commands off the top of my head, but Nitz should be able to help you with that one.
(or find an example and copy it  ;)  )

Wade007

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 309
  • Last login:April 06, 2017, 01:33:35 pm
  • A MAME cabinet at home is heaven
    • bit.ly/1cWnoIC
    • Cheapskategamer.com
Re: Pre command & post command
« Reply #31 on: February 01, 2013, 03:23:21 am »
SUCCESS!!!!   :woot

I posted this same solution on this thread:
http://forum.arcadecontrols.com/index.php/topic,130016.0.html

Between trying to understand Pre/Post command structure here (Thank you drventure!!) and AHK scripting along with how Howard_Casto's wrapper worked in the other (Thanks to nitz, Howard_Casto and BadMouth), I finally figured out how to do it.

Perhaps there's another way to do what I was trying to do but for me it involved using the Pre/Post Commands in Mala along with a carefully crafted AHK script. All this to keep the functionality of Howard's excellent VP wrapper intact (and not loose focus) while still being able to add a bit more functionality for my X-Arcade tankstick. I also wanted to keep with my consistent 2 button exit format along with the rest of the emulators on my arcade cabinet.

Now the SOLUTION!!

First I tweaked my AHK script (VPControls.ahk) for the Pre-Command in Mala. I suppose I could have compiled it to be an .exe, but the simple .ahk format ended up working just fine:

______________________________________

SetWorkingDir, C:\Arcade\Visual Pinball\
#SingleInstance force

~LButton::g ; Nudge Right remap. The "~" is required. Otherwise focus is lost on some tables. Somehow V.P. "clicks" left on tables to begin.
~LButton::d ; Nudge Left Control remap

~2 & ~4::
Send {Esc DOWN} ; Esc key MUST be held for for a bit in order to register with the wrapper. Thanks Howard for the head up.
Sleep 1000 ; keeps the Esc key down for one second
Send {Esc UP}
Sleep 500 ; putting in this small pause seemed to help
ExitApp ; Closing AutoHotKey.exe here rather than in the Post command proved to be possible after all.
return

______________________________________

Then I set up Mala as follows so Howard's wrapper and the AHK script would play nice together. Pre/Post commands were the vital parts:

EXECUTION TAB
Pre Command:
cmd /c start "" "C:\Arcade\Visual Pinball\VPControls.ahk"

Command line (same as always):
"%rom%.%ext%"

Post Command:
(NONE/EMPTY - Not needed because I set up the closing of the ahk script within the script itself)


BASICS TAB (same as always to launch Howard's wrapper):
Executable (keeping the wrapper as the launcher):
C:\Arcade\Visual Pinball\vp-launch6.exe

Rom Path
C:\Arcade\Visual Pinball\Tables

Rom Extensions:
vpt
 

And that's it!! From Mala/Visual Pinball I can launch any table from the menu. The ahk script sets a few controls I couldn't remap otherwise and stays running in the background. Mala then launches Howard's excellent wrapper (vp-launch6.exe). The wrapper takes control of Visual Pinball and plays the table accordingly WITH the added controls of the ahk script. There is no conflicts or loss of focus. I can nudge using the 2nd flipper buttons now on my X-Arcade!! Then, when I'm done playing that particular table I press the 2+4 buttons together (on my X-arcade, not keyboard) and BAM! I'm back to the Mala menu and BOTH Visual Pinball AND AutoHotkey.exe have been closed!!! I tested this over and over on many different tables. Works like a champ.

I hope this thread helps someone else with a similar goal in mind.

Thanks again everyone who chimed in on this thread (drventure, BadMouth, Gray_Area, PaTrYcK). Thanks for your help and knowledge.

« Last Edit: February 01, 2013, 03:27:24 am by Wade007 »
My Super Arcade cabinet project:
Software blog article: http://bit.ly/1cWnoIC

Hardware blog article: http://bit.ly/1dWxjvP

YouTube video: http://bit.ly/1N818Xm

Super Arcade Cabinet Progress thread (Now Complete):
http://forum.arcadecontrols.com/index.php/topic,123292.0.html

Frontend Video Intro: http://bit.ly/1P9HPDN

drventure

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4152
  • Last login:April 23, 2024, 06:53:06 pm
  • Laser Death Ray Bargain Bin! Make me an offer!
Re: Pre command & post command
« Reply #32 on: February 01, 2013, 08:54:19 am »
Awesome! Glad to hear you got it working.

Closing out AHK on the keypress was a nice touch. Makes it much cleaner.