Author Topic: Focus problem using batch for pcsx2  (Read 10938 times)

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
Focus problem using batch for pcsx2
« on: November 08, 2018, 12:33:58 AM »
So normally I've been running my pcsx2 games with the standard args in the cfg.  Like this for example:
Code: [Select]
executable           E:\pcsx2\pcsx2.exe
args                 "[romfilename]" --nogui --fullscreen --fullboot
rompath              E:\Sony Playstation 2\isos\Amplitude (USA)
ext                  .iso


Recently I decided to try batch files instead, so I switched over to this:
Code: [Select]
executable           cmd
args                 /c "[romfilename]"
rompath              E:\Sony Playstation 2\batchfiles
romext               .bat


The problem i'm having with the batch method, is every time I start a game in AM, it will boot but will be playing in the background with AM in focus instead.   I'm not sure what i'm doing wrong, or even how to fix this.  Here is a sample of a batch file for a game:
Code: [Select]
@echo off

d:
cd /D "E:\pcsx2\"
start pcsx2.exe "E:\Sony Playstation 2\isos\Amplitude (USA)\Amplitude (USA).iso" --nogui --fullscreen --fullboot

Anyone have a clue on how to fix this?
« Last Edit: November 08, 2018, 12:38:12 AM by dukpoki »

hermine.potter

  • Hero Member
  • *****
  • Posts: 767
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #1 on: November 08, 2018, 01:15:08 AM »
What happens, if you set the resfix plugin to your emulator-display?
start AM > press TAB key > Plug-ins > ResFix > Enabled : Yes > Specific Emulators : name_of_your_emulator_display
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

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #2 on: November 08, 2018, 09:22:37 AM »
What happens, if you set the resfix plugin to your emulator-display?
start AM > press TAB key > Plug-ins > ResFix > Enabled : Yes > Specific Emulators : name_of_your_emulator_display

Just tried it.  It didn't help.  PCSX2 is still running in the background.

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #3 on: November 08, 2018, 12:18:41 PM »
I have another problem.  I tried creating batch files for Retroarch using a Sega CD game and tested it in AM to see if the same thing would happen (focus lost in the background) however, with the Retroarch batch, the game doesn't even boot at all.  Using Attract-console, I see that it launches the batch once selected but nothing ever transpires from it.  Note that the batch itself works perfectly fine when you double click it outside of AM.

Codes are as follow:

Code: [Select]
executable           cmd
args                 /c "[romfilename]"
rompath              E:\Emulation Data\Sega Genesis & CD\links
romext               .bat
system               Sega CD


Code: [Select]
@echo off

cd /D "E:\Running Emus\RetroArch\"
start retroarch.exe -L "E:\Running Emus\RetroArch\cores\genesis_plus_gx_libretro.dll" "E:\Emulation Data\Sega Genesis & CD\Sega CD isos\Snatcher (USA)\Snatcher (USA).cue"

I've also tried an alternative batch method which resulted in the same thing.

Code: [Select]
@echo off

start "" "E:\Running Emus\RetroArch\retroarch.exe" -L "E:\Running Emus\RetroArch\cores\genesis_plus_gx_libretro.dll" "E:\Emulation Data\Sega Genesis & CD\Sega CD isos\Snatcher (USA)\Snatcher (USA).cue"

xod

  • Full Member
  • ***
  • Posts: 25
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #4 on: November 08, 2018, 01:00:11 PM »
Note that the batch itself works perfectly fine when you double click it outside of AM.

Same thing is observed by me launching AM -> MAME 0.78, vs launching MAME 0.78 directly (without AM). Runs fine without AM, but with AM I have to either have any random application('s window) set to "always on top", or have terminated Explorer.exe (the shell), or run AM in windowed mode. Just for the purpose of gathering knowledge, have you tried having some application window "always on top" (while NOT minimizing that window) ? Try Task Manager and click menu item Options -> Always On Top. Then without minimizing that Task Manager window, launch AM and a game/bat, will it work then ? If yes, then we at least know that you are likely suffering the same probelm as me. To further verify, you should download Process Monitor. It's available for download at microsoft: https://docs.microsoft.com/en-us/sysinternals/downloads/procmon

If you download Process Monitor, I can help you to create a filter (not related to AM filters) for pcsx2.exe, and see how long/short that process runs. There is far more info provided by Process Monitor, but as I'm new and haven't learned much, I will go no further. And I write "help" because Process Monitor filters can be confusing for the beginner, but simple once you grasp them. If you're interested let me know.
« Last Edit: November 08, 2018, 01:53:07 PM by xod »

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #5 on: November 09, 2018, 07:13:03 AM »
Note that the batch itself works perfectly fine when you double click it outside of AM.

Same thing is observed by me launching AM -> MAME 0.78, vs launching MAME 0.78 directly (without AM). Runs fine without AM, but with AM I have to either have any random application('s window) set to "always on top", or have terminated Explorer.exe (the shell), or run AM in windowed mode. Just for the purpose of gathering knowledge, have you tried having some application window "always on top" (while NOT minimizing that window) ? Try Task Manager and click menu item Options -> Always On Top. Then without minimizing that Task Manager window, launch AM and a game/bat, will it work then ? If yes, then we at least know that you are likely suffering the same probelm as me. To further verify, you should download Process Monitor. It's available for download at microsoft: https://docs.microsoft.com/en-us/sysinternals/downloads/procmon

If you download Process Monitor, I can help you to create a filter (not related to AM filters) for pcsx2.exe, and see how long/short that process runs. There is far more info provided by Process Monitor, but as I'm new and haven't learned much, I will go no further. And I write "help" because Process Monitor filters can be confusing for the beginner, but simple once you grasp them. If you're interested let me know.

FYI, I just tried the task manager with Always on Top enabled but it didn't work for me.  PCSX2 still runs in the background with AM in focus instead.

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #6 on: November 09, 2018, 08:18:09 AM »
Update: I fixed the pcsx2 problem.  The issue was the "start" in the batch code.  Once I removed it, AM now properly gives focus to PCSX2.

So i went from this:

Code: [Select]
@echo off

cd /D "E:\pcsx2\"
start pcsx2.exe "E:\Sony Playstation 2\isos\Amplitude (USA)\Amplitude (USA).iso" --nogui --fullscreen --fullboot

to this:

Code: [Select]
@echo off

cd /D "E:\pcsx2\"
pcsx2.exe "E:\Sony Playstation 2\isos\Amplitude (USA)\Amplitude (USA).iso" --nogui --fullscreen --fullboot

And that magically did the trick!

Still can't figure out why RA is not working though.  Again, it doesn't even boot at all.

xod

  • Full Member
  • ***
  • Posts: 25
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #7 on: November 09, 2018, 01:47:24 PM »
When I first your first comment, and before reading the scipt you included, I was about to suggest "start /c ..." as well. But as it turned out for you, that was a/the problem.   Btw, there are plenty crazy things about cmd.exe, enough to make Bash to appear quite sane, hehehe. No command substitution being one, you instead have to use:

Code: [Select]
for /f ["<options>"] %<single-letter-variable> in ('<substituted command>') do <processing command goes here, it has access to %single-letter-variable, which is the output of 'substituted command'>
(the percent character/sign must be doubled (%%) in scripts of course, single ones are only for immediate commandline)

And there are limitations as well as dangers with that workaround.
Also, sometimes in cmd.exe you have to use "cmd /c <command>" rather than just "<command>", or things won't behave as expected and break. It's a mess, and more so to remember all these exception-al behaviors.

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #8 on: November 10, 2018, 09:28:38 AM »
Another update:

I've done some N64 RetroArch batches and they work fine with AM.  It only seems to be my Sega CD batch that doesn't work.  Upon further testing I think the problem is the directory naming convention (look at the rompath in particular).

Currently my directory looks like this:

Code: [Select]
executable           cmd
args                 /c "[romfilename]"
rompath              E:\Emulation Data\Sega Genesis & CD\batch
romext               .bat
system               Sega CD

If I change it to this it works (I'm also moving the actual batch folder in explorer to match of course):

Code: [Select]
executable           cmd
args                 /c "[romfilename]"
rompath              E:\Emulation Data\Sega_CD\batch
romext               .bat
system               Sega CD

So in conclusion, the problem is either the "&", the "CD", or both, probably preceded by a space.  I've tried putting the whole path in quotation which didn't really do anything.  I am now completely stumped as to reasoning why this wouldn't work.  Also another odd thing about all this is that the original rompath with the spaces, "&", and "CD" was working just fine in the rompath field before I started switching over to batches.  Weird.  Of course, the easy solution is to just rename the folder to say "SegaCD" or "Sega_CD", which i'm totally doing.  But it would be nice to understand exactly where and why it's throwing off the code.

EDIT: The problem is the "&".  I've tried "SegaCD CD", "SegaCD &" , "Sega_&".   Anytime there's an "&" it seems to not work.  Still not sure why it doesn't work for batches while "&" is totally fine to use in the rompath any other time.
« Last Edit: November 10, 2018, 09:51:53 AM by dukpoki »

markoattract

  • Full Member
  • ***
  • Posts: 54
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #9 on: May 21, 2020, 11:00:45 AM »
Hello guys and i'm sorry for bump-up this old post ...

I've just tried to insert PCSX2 emulation on Attract Mode , i'm on Windows 10 machine.

i choose to load batch files from PCSX2 and i set this kind of code :

 # Generated by Attract-Mode v2.6.1
#
executable           cmd
args                 /C "[romfilename]"
rompath              S:\Emulazione\ROMS\PS2 ISO-CSO\AMS\batch\
romext               .lnk;.bat
system               PLAYSTATION 2
exit_hotkey          Joy0 Button8+Joy0 Button9
artwork    flyer           
artwork    marquee         
artwork    snap           
artwork    wheel   

So i have the emulator in AM with no issues . When i start a game, it boot up, and i can play it, BUT the focus is on AM palyout yet, so, if i push a button playing ps2 game, just Start another instance of the same game ...

So the problem is that Atttract mode don't "sleep" while i'm playing ps2 game ... Obviusly the issue happens ONLY with PCSX2 ...

Any solution ??? i've just tried the other solution that you have suggested on this topics, but no success ...

Thank you For your answers :D 

rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #10 on: May 21, 2020, 11:19:38 AM »
any specific reason you are using bat files for pcsx2? Call the emulator directly or edit bat files to use this argument > "[romfilename]" --fullscreen --nogui

progets

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1274
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #11 on: May 21, 2020, 11:58:24 AM »
Hello guys and i'm sorry for bump-up this old post ...

I've just tried to insert PCSX2 emulation on Attract Mode , i'm on Windows 10 machine.

i choose to load batch files from PCSX2 and i set this kind of code :

 # Generated by Attract-Mode v2.6.1
#
executable           cmd
args                 /C "[romfilename]"
rompath              S:\Emulazione\ROMS\PS2 ISO-CSO\AMS\batch\
romext               .lnk;.bat
system               PLAYSTATION 2
exit_hotkey          Joy0 Button8+Joy0 Button9
artwork    flyer           
artwork    marquee         
artwork    snap           
artwork    wheel   

So i have the emulator in AM with no issues . When i start a game, it boot up, and i can play it, BUT the focus is on AM palyout yet, so, if i push a button playing ps2 game, just Start another instance of the same game ...

So the problem is that Atttract mode don't "sleep" while i'm playing ps2 game ... Obviusly the issue happens ONLY with PCSX2 ...

Any solution ??? i've just tried the other solution that you have suggested on this topics, but no success ...

Thank you For your answers :D

try adding this to your configuration file

Code: [Select]
nb_mode_wait         x

x = seconds of delay

markoattract

  • Full Member
  • ***
  • Posts: 54
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #12 on: May 22, 2020, 01:22:57 AM »
Hello guys and thank you for the answers !!

any specific reason you are using bat files for pcsx2? Call the emulator directly or edit bat files to use this argument > "[romfilename]" --fullscreen --nogui

Rand0m , i prefer to use the batch files because some games needs DX11 and other needs OpenGL driver, so i need to load PER-GAME configs, and this is possible only with batch files. Or is possible to load configs directly from attract mode Emulator CFG ??

Hello guys and i'm sorry for bump-up this old post ...

I've just tried to insert PCSX2 emulation on Attract Mode , i'm on Windows 10 machine.

i choose to load batch files from PCSX2 and i set this kind of code :

 # Generated by Attract-Mode v2.6.1
#
executable           cmd
args                 /C "[romfilename]"
rompath              S:\Emulazione\ROMS\PS2 ISO-CSO\AMS\batch\
romext               .lnk;.bat
system               PLAYSTATION 2
exit_hotkey          Joy0 Button8+Joy0 Button9
artwork    flyer           
artwork    marquee         
artwork    snap           
artwork    wheel   

So i have the emulator in AM with no issues . When i start a game, it boot up, and i can play it, BUT the focus is on AM palyout yet, so, if i push a button playing ps2 game, just Start another instance of the same game ...

So the problem is that Atttract mode don't "sleep" while i'm playing ps2 game ... Obviusly the issue happens ONLY with PCSX2 ...

Any solution ??? i've just tried the other solution that you have suggested on this topics, but no success ...

Thank you For your answers :D

try adding this to your configuration file

Code: [Select]
nb_mode_wait         x

x = seconds of delay

Progets, thank you for your suggestion, i will try ! :D

UPDATE !!!

Using the NON-BLOCKING-PARAMETER, all is good , BUT i can't exit the game by the controller combo even ... AARGHHH !! i think this is the best that i can have ...

any suggestion ??
« Last Edit: May 22, 2020, 02:03:17 AM by markoattract »

rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #13 on: May 22, 2020, 09:32:00 AM »

Rand0m , i prefer to use the batch files because some games needs DX11 and other needs OpenGL driver, so i need to load PER-GAME configs, and this is possible only with batch files. Or is possible to load configs directly from attract mode Emulator CFG ??


You can create per-game configs, You can use some thing like spectabis (easier) as launcher and use it in Am or use config files directly. I am using the following setup:

Code: [Select]
executable           D:\PlayStation 2\PCSX2 1.5.0 dev-2325 (x32)\pcsx2.exe
args                 "[romfilename]" --fullscreen --nogui --cfgpath="D:\PlayStation 2\Extras\Game Configs\[name]"

1- [name] here means that pcsx2 will look for config file with similar name to currently selected rom - a handy am function
2- Create 2-3 templates like dx11, opengl and software, it will make it easier to manage if you have large romset.
3- spectabis > https://github.com/FaithLV/Spectabis/blob/master/README.md (try not to add any flyers, large list with flyers can cause huge slowdowns)
« Last Edit: May 22, 2020, 09:34:00 AM by rand0m »

progets

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1274
    • View Profile
Re: Focus problem using batch for pcsx2
« Reply #14 on: May 22, 2020, 11:06:47 PM »

Using the NON-BLOCKING-PARAMETER, all is good , BUT i can't exit the game by the controller combo even ... AARGHHH !! i think this is the best that i can have ...

any suggestion ??

Try deleting this line from your AM configuration file and assign/use the buttons/keys inside pcsx2 to exit the emulator. This will exit pcsx2 which will then put focus back on AM (at least is does for me but I might not have the latest pcsx2).

Code: [Select]
exit_hotkey          Joy0 Button8+Joy0 Button9

I'll also mention how I run pcsx2. You can configure it 1000 different ways but here's what I do. First, I only use *.cso games, you can read about it here http://forum.attractmode.org/index.php?topic=2290.msg15484#msg15484.

Then I use this simple Sony PlayStation 2.cfg
Code: [Select]
# Generated by Attract-Mode v2.6.1
#
executable           \Emulators\PCSX2\pcsx2.exe
args                 --nogui --fullscreen --fullboot "[romfilename]"
rompath              \Roms\Sony PlayStation 2
romext               .cso
system               Sony Playstation 2
info_source          thegamesdb.net
artwork    boxart    \EmuMovies\Sony_PlayStation_2\Box_3D;\EmuMovies\Sony_PlayStation_2\Box
artwork    boxbackart    \EmuMovies\Sony_PlayStation_2\BoxBack
artwork    cartart   \EmuMovies\Sony_PlayStation_2\Cart
artwork    fanart    \EmuMovies\Sony_PlayStation_2\Background
artwork    marquee   \EmuMovies\Sony_PlayStation_2\Banner
artwork    snap      \EmuMovies\Sony_PlayStation_2\Video_MP4_HI_QUAL;\EmuMovies\Sony_PlayStation_2\Snap
artwork    title     \EmuMovies\Sony_PlayStation_2\Title
artwork    wheel     \EmuMovies\Sony_PlayStation_2\Logos

If you have a lot of PS2 games this saves a ton of space and loads much faster. It also eliminates the .cue and .bin, multi disc, etc. mess.

I think that if you setup the pcsx2 emulator correctly it will create per game configuration files that will be used each time you launch the game.

Settings in the emulator are just as important, if not more important, as the the AM settings.

Good luck.
« Last Edit: May 22, 2020, 11:41:03 PM by progets »