Author Topic: Launch Decorator plugin  (Read 11313 times)

alucard

  • Full Member
  • ***
  • Posts: 37
    • View Profile
Launch Decorator plugin
« on: March 01, 2021, 01:01:52 PM »
Hi All,
I wrote a plugin to execute script before and/or after game execution.

LaunchDecorator has configurable ScriptRoot (and extensions) and follows convention
over configuration approach to find and run scripts

ScriptRoot
ʉӣ + emulator name
 â”ƒ â”— -- before.{script extension}
 â”ƒ â”— -- after.{script extension}
 â”ƒ â”— ...
 â”ƒ â”— -- before.{game name}.{script extension}
 â”ƒ â”— -- after.{game name}.{script extension}
 â”ƒ â”— ...
 â”ƒ
ʉӣ + another emulator name
ʉӣ +..

All ScriptRoot child elements are optional and script extensions can be mixed.

Plugin and instructions can be found here:
https://github.com/matteocedroni/am-launch-decorator-plugin
« Last Edit: March 01, 2021, 01:04:14 PM by alucard »

manzarek

  • Sr. Member
  • ****
  • Posts: 156
    • View Profile
    • YouTube
Re: Launch Decorator plugin
« Reply #1 on: March 02, 2021, 08:06:01 AM »
Then I create a folder in AT with the name ScriptRoot
inside I create a folder with the name Mame and inside I put the file created bat to open a video, before.bat

Code: [Select]
@echo off
start "vlc" "H:\attract-v2.6.1\ScriptRoot\mame\logo_open.mp4"
exit

when I launch any mame game, the video opens, but then AT freezes, without the game being started after the video, what am I wrong?
Mame Fighting

alucard

  • Full Member
  • ***
  • Posts: 37
    • View Profile
Re: Launch Decorator plugin
« Reply #2 on: March 02, 2021, 10:14:11 AM »
Interesting.

I can investigate but probably it's a windows focus problem.

This particular kind of script runs action that cause AttractMode lose focus. AttractMode can lose focus only after game is launched.

Your needs seems a sort of Fade To/From Game function. A function strictly performed by AttractMode while keeping focus.
FadeToGame plugin exists, but current version doesn't play video.

ReBirFh

  • Jr. Member
  • **
  • Posts: 12
    • View Profile
Re: Launch Decorator plugin
« Reply #3 on: March 02, 2021, 11:29:16 AM »
Sounds useful, can you give some practical examples/use cases?

manzarek

  • Sr. Member
  • ****
  • Posts: 156
    • View Profile
    • YouTube
Re: Launch Decorator plugin
« Reply #4 on: March 02, 2021, 12:35:45 PM »
Your needs seems a sort of Fade To/From Game function. A function strictly performed by AttractMode while keeping focus.
FadeToGame plugin exists, but current version doesn't play video.
Exactly I wanted to use it for this purpose, a kind of video loading of games.
Mame Fighting

ReBirFh

  • Jr. Member
  • **
  • Posts: 12
    • View Profile
Re: Launch Decorator plugin
« Reply #5 on: March 02, 2021, 12:53:59 PM »
Your needs seems a sort of Fade To/From Game function. A function strictly performed by AttractMode while keeping focus.
FadeToGame plugin exists, but current version doesn't play video.
Exactly I wanted to use it for this purpose, a kind of video loading of games.

This seems to be one of the most wanted thing in a Brazilian AM group I'm part of.  People hate to see comand line and/or the emulator loading when starting a game, they want a seamless transition from AM to game
« Last Edit: March 03, 2021, 01:44:42 PM by ReBirFh »

hermine.potter

  • Hero Member
  • *****
  • Posts: 767
    • View Profile
Re: Launch Decorator plugin
« Reply #6 on: March 03, 2021, 03:08:03 AM »
nice idea and work.
Have tried do to something similar here

I'm trying to start JoyToKey with profile load before and close after with your plugin:

this batch content starts before:
Code: [Select]
@echo off
start "" "C:\attract\JoyToKey\JoyToKey.exe" "C:\attract\JoyToKey\ZSNES.cfg"
exit

but if i try this batch content after, AM stucks and crash:
Code: [Select]
@echo off
taskkill /F /IM "JoyToKey.exe"
exit

I think it crashes because of commandline popup, if taskkill starts.
do you have an idea to solve focus problem?
AM Version : 2.6.1
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : Windows10 Pro
System : Dell Precision T3500 ; Intel X5650 ; 12GB RAM

alucard

  • Full Member
  • ***
  • Posts: 37
    • View Profile
Re: Launch Decorator plugin
« Reply #7 on: March 03, 2021, 03:47:30 AM »
Quote
I think it crashes because of commandline popup, if taskkill starts.
do you have an idea to solve focus problem?

Popups, windows and interactive actions outside Attract-Mode must be avoided before/after game.

So you can try to hide taskkill

Anyway, I'll try some possible fix to reduce lost focus occurrence

hermine.potter

  • Hero Member
  • *****
  • Posts: 767
    • View Profile
Re: Launch Decorator plugin
« Reply #8 on: March 03, 2021, 01:20:46 PM »
all already tried before posting (autoit, vbs, /min command).
even invisible compiled bat2exe ^-^

then I have used the plugins from here again (based on ResFix.nut Plugin).

was able to start before:
Code: [Select]
system( "start /MIN \"\" \"C:\\attract\\JoyToKey\\JoyToKey.exe\" \"C:\\attract\\JoyToKey\\ZSNES.cfg\"" );
or
system( "start /MIN \"\" \"C:\\attract\\JoyToKey\\JoyToKey.exe\" \"C:\\attract\\JoyToKey\\" + fe.game_info( Info.Emulator )+ ".cfg\"" );
or
system( "\"C:\\attract\\scripts\\" + fe.game_info( Info.Emulator )+ "\\before.bat\"" );

and after:
Code: [Select]
system( "taskkill /F /IM JoyToKey.exe" );
or
system( "\"C:\\attract\\scripts\\" + fe.game_info( Info.Emulator )+ "\\after.bat\"" );

it works with focus, popups, no AM crash.
so there is something in ResFix.nut Plugin, that handle the correct focus?!
squirrel language is not my favourite and I'm not a squirrel expert ^-^
AM Version : 2.6.1
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : Windows10 Pro
System : Dell Precision T3500 ; Intel X5650 ; 12GB RAM

alucard

  • Full Member
  • ***
  • Posts: 37
    • View Profile
Re: Launch Decorator plugin
« Reply #9 on: March 04, 2021, 01:15:01 AM »
Ok,

so system function may be the solution  :D

I have attached a modified version of plugin.nut, using system function instead of fe_plugin_command.

Can you try if this fixes focus problem?

Thanks

hermine.potter

  • Hero Member
  • *****
  • Posts: 767
    • View Profile
Re: Launch Decorator plugin
« Reply #10 on: March 05, 2021, 12:33:29 AM »
thank you for programming. works perfect.
very good work.

often its necessary to start programs before and close them after.

the script/plugin now expand AM with an important feature ^-^
AM Version : 2.6.1
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : Windows10 Pro
System : Dell Precision T3500 ; Intel X5650 ; 12GB RAM

manzarek

  • Sr. Member
  • ****
  • Posts: 156
    • View Profile
    • YouTube
Re: Launch Decorator plugin
« Reply #11 on: March 05, 2021, 10:55:43 AM »
works perfect. :D
Anyone know what is the syntax to close the video? i tried this but it doesn't work

after:
Code: [Select]
@echo off
taskkill /F /IM "logo_open.mp4"
exit
« Last Edit: March 05, 2021, 11:04:25 AM by manzarek »
Mame Fighting

alucard

  • Full Member
  • ***
  • Posts: 37
    • View Profile
Re: Launch Decorator plugin
« Reply #12 on: March 06, 2021, 02:14:54 AM »
Quote
Anyone know what is the syntax to close the video? i tried this but it doesn't work

I don't think you can close the video killing it directly, but you can kill VLC

Code: [Select]
taskkill /F /IM "vlc.exe"
If you want to make VLC automatically quits itself after playing video, you can modify launch command to

Code: [Select]
start "vlc" "H:\attract-v2.6.1\ScriptRoot\mame\logo_open.mp4" "vlc://quit"

manzarek

  • Sr. Member
  • ****
  • Posts: 156
    • View Profile
    • YouTube
Re: Launch Decorator plugin
« Reply #13 on: March 06, 2021, 02:24:30 AM »
Thanks I'll try. :)
Mame Fighting