Jump to content
LaunchBox Community Forums

AHK vs Batch


djm59

Recommended Posts

Hello all,

I'm a new user of Launchbox, using in the past some dedicated distributions like batocera.
The migration from Batocera to Launchbox is coming with some improvments on my bartop :

- a controler for the led of my buttons
- a new keyboard controler for my control panel (joystick controler before)
- a DMD in place of  the marquee (:p)

For these, i have lot of commands to launch in scripts with my emulators.
I tried to do the job with AutoHotKey script (Running script in the emulator panel) but i have some difficulties.

For Exemple : For PinballFX2, i have this kind of script :
 

; Stop the actual DMD Display
Run, "C:\Pixelcade\pixelcade-quit.exe", "C:\Pixelcade", Hide

; start the DMD for Pinball
Run, "C:\Program Files\Creative Arts and Technology\Pixelcade Pinball Display\dmdext.exe" "mirror" "--source=pinballfx2" "-q" "--no-virtual", "C:\Program Files\Creative Arts and Technology\Pixelcade Pinball Display", Hide

; Switch control panel
Run, "C:\Program Files (x86)\WinIPAC V2\WinIPAC.exe" "d:\Ipac2\PinballFX2.ipc", "d:\Ipac2\", Hide

;Kill
$Esc::
{
   Process, Close, {{{StartupEXE}}}
	; relaunch DMD
    Run, "C:\Pixelcade\pixelweb.exe", "C:\Pixelcade", Hide
	; re swtich keyboard configuration
    Run, "C:\Program Files (x86)\WinIPAC V2\WinIPAC.exe" "d:\Ipac2\Defaut.ipc", "d:\Ipac2\", Hide
}


It's not perfect, but working. 
But when i have a look to the running process list when i'm starting/stoping a game, i see lot of "Winipac.exe" running, as if the executables remained in memory.
and if the software needs a console (like dmdext), it can have negative effects on startup, such as not supporting command line parameters.
(i hope to make myself understood, i am French and my English is average :s )

To prevent this, i'm using Batch script in place of my emulator. Always in the same exemple : i'm using pinballfx2.bat instead of "pinball fx2.exe" with this content : 

@echo off

rem switch Keyboard
call "C:\Program Files (x86)\WinIPAC V2\WinIPAC.exe" "d:\Ipac2\PinballFX2.ipc"

rem remove standard DMD Display
call "C:\Pixelcade\pixelcade-quit.exe"

rem load the DMD for Pinball
cd /d C:\DmdPinball
start /min dmdext.exe mirror --source=pinballfx2 --no-virtual -q --fps 60
cd /D "D:\Games\Pinball FX2\"

rem Launch Main Executable with good table
call "D:\Games\Pinball FX2\Pinball FX2.exe" %1

rem switch standard settings for control panel
call "C:\Program Files (x86)\WinIPAC V2\WinIPAC.exe" "d:\Ipac2\Defaut.ipc"

rem reload standard DMD
start /min cmd /c "C:\Pixelcade\pixelweb.exe"

exit 0

It's working better, no zombie process running, and the job is done.

BUT...
I have the impression of not understanding someting and doing "old school" work.
Can someonehelp me on AHK,so that i can correct my problem ?

Many thanks.

J.

 

 


 

 

Edited by djm59
Link to comment
Share on other sites

7 hours ago, djm59 said:

i see lot of "Winipac.exe" running, as if the executables remained in memory.

That's weird because I though Winipac simply tells your I-Pac to 'set the controls "this way"', then exits.  A couple things you will want to do in your $Esc routine is to move the last 2 commands before closing the 'emulator' and change "Process" to "WinClose".

;Kill
$Esc::
{
   ; relaunch DMD
   Run, "C:\Pixelcade\pixelweb.exe", "C:\Pixelcade", Hide

   ; re swtich keyboard configuration
   Run, "C:\Program Files (x86)\WinIPAC V2\WinIPAC.exe" "d:\Ipac2\Defaut.ipc", "d:\Ipac2\", Hide

   WinClose, ahk_exe {{{StartupEXE}}}
}

As soon as you Close the Emulator (via Process, Close or WinClose), the Running AutoHotkey script is abandoned.  So you want to run those 2 apps before closing the game. (Otherwise they won't execute.)

Also, "WinClose" is 'nicer' than using "Process, Close".  "Process" KILLS it in its tracks, while "WinClose" allows it to 'exit gracefully'. :) 

Link to comment
Share on other sites

Does not work 😢

WinIpac.exe stays in memory :
image.thumb.png.14f54f7bdf5299b3df21923b85408d3b.png

And another unwanted effect : DMDext (management of the DMD) keep the focus, and make the main executable in second plan. I must ALT+TAB to continue with it 😞

My actuel AHK Script (it's for Pinball FX2) :

; Stop the actual DMD Display
Run, "C:\Pixelcade\pixelcade-quit.exe", "C:\Pixelcade", Hide

; Switch control panel
Run, "C:\Program Files (x86)\WinIPAC V2\WinIPAC.exe" "d:\Ipac2\PinballFX2.ipc", "d:\Ipac2\", Hide


; start the DMD for Pinball
Run %ComSpec% /c "C:\DmdPinball\dmdext.exe mirror --source=pinballfx2 -q --no-virtual", "C:\DmdPinball\",Hide
sleep, 4000 ;(wait 4 seconds)

;Kill
$Esc::
{
	; relaunch DMD   
	Run, "C:\Pixelcade\pixelweb.exe", "C:\Pixelcade", Hide

	; re swtich keyboard configuration
	Run, "C:\Program Files (x86)\WinIPAC V2\WinIPAC.exe" "d:\Ipac2\Defaut.ipc", "d:\Ipac2\", Hide

	 WinClose, ahk_exe {{{StartupEXE}}}
}

i can not get the same resultat as my .bat file and i don't understand why 😢

 

Link to comment
Share on other sites

2 hours ago, djm59 said:

understand why

In your batch file (which is being used "as the emulator") your first 'command' is to load the I-Pac configuration.  You're using "call" to run it (vs "start").  "call" will wait for the executable [in that command] to exit before going to the next command listed.

The AHK script (which you put in you Running [AutoHotkey] Script) is running the 3 commands [basically] all at the same time (not waiting on one another before starting the next).  It is also running these 3 at the same time as starting pinballfx2.  So 4 programs are being executed [essentially] at the same time.  (You can't really use RunWait here as it might just make matters worse.)  DMDext might be taking a little longer to completely load up. So probably, when pinballfx2 says "I'm ready to go", DMDext THEN says "me too".  After FX2, so taking focus.

That still doesn't really explain why WinIpac.exe keeps 'hanging around' when using the [Running AutoHotkey script] AHK.

I have never changed the configuration on my [really OLD] I-Pac mini because it works as-is and I'm scared to screw it up. ;) So I won't run any tests with it here.

 

You might try..... (for testing and troubleshooting)

Create a batch file with just this:

@echo off

rem switch Keyboard
call "C:\Program Files (x86)\WinIPAC V2\WinIPAC.exe" "d:\Ipac2\PinballFX2.ipc"

rem remove standard DMD Display
call "C:\Pixelcade\pixelcade-quit.exe"

rem load the DMD for Pinball
cd /d C:\DmdPinball
start /min dmdext.exe mirror --source=pinballfx2 --no-virtual -q --fps 60
cd /D "D:\Games\Pinball FX2\"

 

Edit one your tables, go to Additional Apps and Add Application.  Under Application Path, Browse to and select your [above] batch file.  Check the boxes Automatically Before Main Application and  Wait for Exit.  Click OK to save that and close the Edit window.

Now edit you PinballFX2 emulator and in the Running Script tab, remove everything above "kill;" and save.

Make sure you don't have any old WinIpac V2 processes running in Task Manager.

Launch that table, play a little because it's fun :), exit the Table and check your Task Manager.

See if that changes anything [for THAT table].

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...