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: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps [SOLVED]  (Read 9445 times)

0 Members and 1 Guest are viewing this topic.

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
I'm running Visual Pinball on Mala and found a great, working, wrapper from Howard_Castro here:
http://forum.arcadecontrols.com/index.php/topic,117950.0.html

The problem is that I'd like to remap a few keys; 2-button exit combo to ESC and the Mouse 1 & 2 buttons to other keys on my X-Arcade Tankstick while it's running.

I figured I'd just create a Auto Hot Key script to launch the wrapper (vp-launch6.exe), pass the table name, and then make the keystoke re-map changes. This new AHK script would only run when I launch Visual Pinball. The problem seems to be with the passing of the table name from the Command line. I think... The Script seems to launch the wrapper OK but then gives me an error "52-can't find file".

When I run the wrapper directly from Mala it works fine (without the desired re-maps) and is able to pick up the pinball table selected.

How can I run an AHK script along with this wrapper (vp-launch6.exe)?

Below is my current, NON-working AHK code. Maybe there's another way to do this and I'm just making it more complicated than it needs to be? When compiled it I call this script's executable "VP Table Launcher.exe". I believe it's the Run line I need help with the most.

___________________________________

#NoEnv
SendMode Input
SetWorkingDir, C:\Arcade\Visual Pinball\
#SingleInstance force

Run, "vp-launch6.exe" /open "C:\Arcade\Visual Pinball\Tables\%1% /play /exit ; There's something wrong with this line!!! How to pass table name? Some of this code was borrowed from my Future Pinball wrapper. Needs to be tweaked.

LButton::D
RButton::G

~2 & ~4::
Send {Esc}

ExitAPP
return

___________________________________


In Mala's settings I just tried to point it to the new executable (VP Table Launcher.exe) I created (using above non-working code) instead of vp-launch6.exe as before (working). All other settings are the same. So essentially I have an .exe launching another .exe. A wrapper around a wrapper. Will that work? Mala's settings are as follows:

Executable:
C:\Arcade\Visual Pinball\VP Table Launcher.exe

Previous Executable (working):
C:\Arcade\Visual Pinball\vp-launch6.exe

Rom Path:
C:\Arcade\Visual Pinball\Tables

Rom Extensions:
vpt

Execution/Command Line:
"%rom%.%ext%"

 :dunno

Thanks in advance for any help.
« Last Edit: February 01, 2013, 03:14:17 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

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9270
  • Last login:Today at 01:30:54 pm
  • ...
Re: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #1 on: January 28, 2013, 10:53:00 am »
I'm not running Visual Pinball, but IIRC a script needs to be compiled into an exe for the variable to be passed to it.
There is a utility that comes with autohotkey that will do this for you.
In fact, I think if you right click on your script, it will show the option to convert it to an exe.

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: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #2 on: January 28, 2013, 12:43:32 pm »
Thanks Badmouth. I'm aware that the AHK script needs to be compiled into an .exe.
I've done that, but my code is somehow wrong.

I'm not sure how to pass the name of the table through the AHK.exe to Howard_Casto's vp-launch.exe
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

nitz

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 507
  • Last login:November 24, 2015, 07:57:29 pm
Re: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #3 on: January 28, 2013, 11:44:04 pm »
Let's leave Mala and ahk out of the equation for a minute.

Can you open a table using the wrapper from the command line? If you can do that, we should be able to figure out how to get ahk to do 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: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #4 on: January 29, 2013, 11:34:19 am »
Thanks Nitz for your response. I was really hoping I'd get your attention on this one. :)

When I open Howard_Castro's wrapper separately, I am able to open a play any VP table just fine. Works perfectly. Plays any table outside of Mala and without an AHK script.

My next step was to use it with Mala. Pointed Mala to the wrapper .exe. Again, worked fine. Picks up the selected pinball table name from the menu correctly.

My third step was to try and remap a few keys that couldn't be done anywhere else. That's where the trouble is. I'm sure that AHK is my best bet. I just can't figure out how to do it.

One other theory would be to run the AHK script in Pre/Post commands. I'm still trying to figure that one out as well.
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

nitz

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 507
  • Last login:November 24, 2015, 07:57:29 pm
Re: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #5 on: January 29, 2013, 07:11:01 pm »
Run, "vp-launch6.exe" /open "C:\Arcade\Visual Pinball\Tables\%1% /play /exit ; There's something wrong with this line!!! How to pass table name? Some of this code was borrowed from my Future Pinball wrapper. Needs to be tweaked.

You know, I wonder if the solution to this could be as simple as the fact that you're missing the end quote after the table name. ;)

Also, I would put return right underneath that command so it doesn't fall through and activate the hotkeys underneath.

Give it a try and see what happens.

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: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #6 on: January 29, 2013, 07:35:44 pm »
Thanks nitz, I'll give it a go and report back.

I did catch the end quote missing and added it back in to no avail.

Let me goof around a bit more tonight and I'll let you know if I make any more headway.

Do you think I need some sort of "WinWait" command as well for the Visual Pinball window?

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

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Yesterday at 11:38:27 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #7 on: January 29, 2013, 08:02:56 pm »
Or it could be that this command line you are passing has absolutely nothing to do with my wrapper.  ;)

Taken straight from the readme:
=====================================================
Command-line Usage
==================
VPL is obviously supposed to be used within a front-end.  The command line options
couldn't be easier:

vp-launch6.exe "c:\visual pinball\tables\table.vpt"

or you can omit the path if it's in the "tables" directory like so:

vp-launch6.exe "table.vpt"


Quotes aren't required, but they are reccomended.
===========================================


So why are you sending command lines like you are trying to launch a table WITHOUT a wrapper?  That's not how it works man. 

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: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #8 on: January 30, 2013, 02:42:06 am »
OK, I took a clue from Howard_Casto on his wrapper command line comment and cleaned up my code. I had figured out that Readme info when setting up Mala but not when writing this script. I also added the quote at the end of the first line per nitz' suggestion. That probably helped too. The resulting good news is that I can now launch the correct table with the AHK script with Mala.

However, I'm still not quite there. With the following script, I can launch the correct table, but the regular controls like entering a credit, flippers, etc., don't work because the script is the active program not VP. It's like it's waiting the script to quit before it gives me control of VP. I have to enter my two button exit combo to quit the AHK script (doesn't affect VP as intended). It then sends me back to Mala, but the tableis still running in the background. If I reselect the background window running the VP table, I can play it normally but without the use of any remapped keys (since the ahk script ended):

______________________________________

Run, "vp-launch6.exe" C:\Arcade\Visual Pinball\Tables\%1%"

LButton::d ; 1st re-mapped key
Rbutton::g; 2nd re-mapped key

~2 & ~4::
Send {Esc} ; ESC is what quits the Visual Pinball Wrapper and sends me back to Mala normally. Can't be remapped within VP or the wrapper.
ExitAPP
return

______________________________________

The problem is I'm no expert with AHK. My loose theory is I need to insert some sort of "WinWait ahk_class VPinball" type coding to make sure the remapped keys work WHILE running Visual Pinball, but I'm not sure how to do that.  :dunno  Does that sound remotely right? Sorry I'm an idiot.

Again, all I'm trying to do is re-map a couple of keys that I can't do otherwise and exit both the AHK script and Howard's wrapper together using the 2+4 keystrokes when I'm done playing a table. Howard's wrapper is great (that's why I'm trying so hard to stick with it). I just want added control of VP using my X-Arcade tankstick and a consistent exit key combo to match my other emulators on my cabinet. :)

Thanks for your patience with me guys (nitz and Howard_Casto). Please hang in there with me a bit longer? Please! I'd appreciate any more insight.  :notworthy:


« Last Edit: January 30, 2013, 02:55:02 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

nitz

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 507
  • Last login:November 24, 2015, 07:57:29 pm
Re: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #9 on: January 31, 2013, 02:23:28 am »
If the problem is that the window is losing focus for some reason, you could try this:

Run, "vp-launch6.exe" C:\Arcade\Visual Pinball\Tables\%1%"

WinWait, WindowTitle ; waits for the Visual Pinball window to exist
WinActivate, WindowTitle ; makes Visual Pinball the active window

LButton::d ; 1st re-mapped key
Rbutton::g; 2nd re-mapped key

~2 & ~4::
Send {Esc} ; ESC is what quits the Visual Pinball Wrapper and sends me back to Mala normally. Can't be remapped within VP or the wrapper.
ExitAPP
return

Where WindowTitle is the first few case-sensitve letters of the Visual Pinball window. If it's not always the same, put SetTitleMatchMode, 2 at the top of the script. Then you can use any text that appears anywhere in the window's title.

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Yesterday at 11:38:27 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #10 on: January 31, 2013, 03:54:22 am »
That's probably not going to work.  The vp wrappers are extremely sensitive to losing focus.  The game would never launch properly. 

Like I said before just have the ahk running all the time, put it in your startup folder or something.  You'll need it anyway as there are very few emulators outside of mame that allow you to bind a key combo to the exit button.

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: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #11 on: January 31, 2013, 12:38:27 pm »
Thanks guys,
I tried nitz' suggestion with the WinWait/WinActivate coding but I'm still having the similar trouble. Maybe Howard is right about his wrapper and the focus issue.

Mmmmm....New idea... Use the Pre/Post commands to launch the key-mapping AHK script before vp-launch6.exe is launched???

[...runs away to test]

I did some experimenting and had more success!

First, 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 that there is no ExitAPP & Return after this line to keep the script running. Need 'Return'?

_________________________________

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 worked for the most part! the remaps work with the tables as intended!!

Two minor problems:

The "taskkill" command line doesn't seem to work. Is there a better way to kill AutoHotkey running in the Post Command? I can't keep it always running as suggested because the controls set up will only help me in Visual Pinball.

When I use the "taskkill" command It doesn't give me an error but AutoHotKey.exe is still running in the background. I get sent back to the Mala menu but the Controls script is still running. How to end the script for good after vp-launch6.exe quits? Run the script as an .exe? Use a BAT file to open and close the AHK scripts in the Pre/Post command areas?

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. I don't want to see "Quit to Editor/Resume Game/etc.." Just quit the whole thing like the wrapper did everytime. 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 the script running fine and not interfering with the wrapper, my 2+4 key acts as if VP was running alone. Any ideas on how to truly send the escape key? How is that best done Howard? Perhaps a different AHK code like Send {Down ESC} or something?

So it looks like I'm about 90% there. Very close. I can smell it. Any ideas on these last two issues?

Again...thanks a ton.  :notworthy: I bow to your knowledge and skill.
« Last Edit: January 31, 2013, 12:49:07 pm 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

BadMouth

  • Trade Count: (+6)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9270
  • Last login:Today at 01:30:54 pm
  • ...
Re: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #12 on: January 31, 2013, 01:05:36 pm »
Just an observation....

Postcommand:
taskkill VPControls.ahk

but you mentioned elsewhere that you had compiled it to an exe

You probably switched to using the .ahk, but figured I'd point it out just in case.


Nitz, my thinking is to use Close, Process to kill VP, then IfWinActive or IfWinNotActive to get the script to exit.




Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19427
  • Last login:Yesterday at 11:38:27 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #13 on: January 31, 2013, 02:45:13 pm »
Yeah a simple "send" is not going to work in ahk because the wrapper requires you to hold the key down (even if it's for a very short time). 

You are going to have to split that out so that there is a up and down section, and essentially the ESC key is held for as long as you hold both 2 and 4.  There are examples of how to do this in the ahk documentation.

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: Need AHK help to launch Visual Pinball Wrapper with new keystoke maps
« Reply #14 on: February 01, 2013, 03:07:59 am »
SUCCESS!!!!   :woot

It's after 1am right now  :dizzy: I've been tweaking and testing this problem all night, but I finally figured it out!!
Well... I wouldn't have found the solution without your help. So first off I want to say "THANK YOU!!" to nitz, Howard_Casto and BadMouth for nudging me in the right direction on what I was trying to accomplish. Also PaTrYcK and drventure from another thread about Pre/Post commands. Thanks for hanging in here with me. You guys are great. Really.  :notworthy:

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 Howard for your excellent VP wrapper!

« Last Edit: February 01, 2013, 03:27:56 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

nitz

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 507
  • Last login:November 24, 2015, 07:57:29 pm
Nice!  :cheers:

Glad you got it figured out. It's been ages since I've played with VP and that wrapper, so frankly, I was pretty much out of ideas. ;)