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: Another fix if you are losing focus when starting emulator from a batch file.  (Read 4702 times)

0 Members and 1 Guest are viewing this topic.

SGT

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1146
  • Last login:May 31, 2025, 10:10:32 pm
I have been having a problem that others have reported where after playing a game in Mame or other emulators you have to click with a mouse before the keys/buttons start working in Mala.  Of course Mala is losing the focus.  Some have written scripts to simulate a mouse click and TheShanMan wrote a nice focuslogger plugin that has helped many.

Unfortunately the plugin could not help my problem.  The log would show that Mala had lost the focus and that nothing else had the focus.  It would then report a failed attempt to give Mala the focus.  I thought it may have something to do with the fact that I launch Mame from a batch file.

Launching Mame from a batch file like this results in the problem:
Code: [Select]
mame %1
It is fixed when I use this instead:
Code: [Select]
start /B mame.exe %1
Hopefully this will help others with the same problem.

loadman

  • Moderator
  • Trade Count: (+3)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 4306
  • Last login:May 26, 2024, 05:14:32 am
  • Cocktail Cab owner and MaLa FE developer
    • MaLa
Ahh,  ;D

So the diff is you are launching in the background ehh?

Very Unix like.

If this is a global solution than should I put in the code that all emu's launch this way?  :dunno

SGT

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1146
  • Last login:May 31, 2025, 10:10:32 pm
If this is a global solution than should I put in the code that all emu's launch this way?  :dunno

Possibly.  I haven't used Mala to launch mame.exe for a long time since I use the batch file method of combining emulators into one game list.   Just for testing, I changed my executable in Mala from mame.cmd to mame.exe just to see if Mala lost focus with my build.  Indeed it did lose focus after exiting a mame game every time.

I went back to using mame.cmd with the contents of "start /B mame.exe" and no longer had the loss of focus problem within Mala.  It is very repeatable so if you wanted to compile a test Mala.exe  which consists of launching mame.exe in a similar fashion then I can test and tell you if the focus issue goes away.  Just let me know. 

I'm sure it would be great if the need to use scripts to simulate a mouse click could be eliminated.

loadman

  • Moderator
  • Trade Count: (+3)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 4306
  • Last login:May 26, 2024, 05:14:32 am
  • Cocktail Cab owner and MaLa FE developer
    • MaLa
Bugger.

The main issue is I have never had the focus issue, I believe that it exists but hard to fix something I can't see.

If someone can give me a certain recipe that would help

SGT

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1146
  • Last login:May 31, 2025, 10:10:32 pm
Loadman,

I am 99.9999% sure that the loss of focus after playing a game is caused by the option to Reorder Layout after Game Quit.  Perhaps you could look at that subroutine and determine how the Mala window is not regaining the focus.  It is not that something is stealing, it's that nothing has the focus.

I am going to start a new thread on this so you are sure to see it since this specific thread implies  a batch file connection.

csa3d

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 872
  • Last login:March 07, 2011, 08:16:35 am
  • Will game for food
    • Galaxian Mame Conversion
I've not been able to have any keyboard encoder which uses an .exe to switch keycodes (for various different emulator configs) ever work properly inside Mala and still retain proper focus.  Wonder if this batch file fix instead of calling the encoder .exe directly will do it.  I'll give it a try for sure.  Thanks for the heads up!

-csa

loadman

  • Moderator
  • Trade Count: (+3)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 4306
  • Last login:May 26, 2024, 05:14:32 am
  • Cocktail Cab owner and MaLa FE developer
    • MaLa
I've not been able to have any keyboard encoder which uses an .exe to switch keycodes (for various different emulator configs) ever work properly inside Mala and still retain proper focus.  Wonder if this batch file fix instead of calling the encoder .exe directly will do it.  I'll give it a try for sure.  Thanks for the heads up!

-csa

That would be good to know.