Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: alucard 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 (https://github.com/matteocedroni/am-launch-decorator-plugin)
-
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
@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?
-
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.
-
Sounds useful, can you give some practical examples/use cases?
-
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.
-
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
-
nice idea and work.
Have tried do to something similar here (http://forum.attractmode.org/index.php?topic=555.msg25163#msg25163)
I'm trying to start JoyToKey with profile load before and close after with your plugin:
this batch content starts before:@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:@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?
-
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
- calling taskkill with a parameter (if supported)
- calling taskkill with start /min https://stackoverflow.com/questions/23057448/open-program-minimized-via-command-prompt (https://stackoverflow.com/questions/23057448/open-program-minimized-via-command-prompt)
- calling preconfigured taskkill link (with current parameters and minimized status)
- calling another tool instead of taskkill
- using another more powerfull script language (vbs, AutoIt, ...) to completely hide all
Anyway, I'll try some possible fix to reduce lost focus occurrence
-
all already tried before posting (autoit, vbs, /min command).
even invisible compiled bat2exe ^-^
then I have used the plugins from here (http://forum.attractmode.org/index.php?topic=555.msg25163#msg25163) again (based on ResFix.nut Plugin).
was able to start before: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: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 ^-^
-
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
-
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 ^-^
-
works perfect. :D
Anyone know what is the syntax to close the video? i tried this but it doesn't work
after:
@echo off
taskkill /F /IM "logo_open.mp4"
exit
-
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
taskkill /F /IM "vlc.exe"
If you want to make VLC automatically quits itself after playing video, you can modify launch command to
start "vlc" "H:\attract-v2.6.1\ScriptRoot\mame\logo_open.mp4" "vlc://quit"
-
Thanks I'll try. :)