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: Can MaLa run an app on startup? ...or why does InstantSheller prevent CPWizard?  (Read 9729 times)

0 Members and 1 Guest are viewing this topic.

sofakng

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 646
  • Last login:February 18, 2021, 04:19:21 pm
I've used InstantSheller on my arcade machine and it works GREAT, but I've now installed CPWizard and selected "Run On Startup" but it never runs.  If I exit my front-end and manually run explorer.exe, then CPWizard will run but it looks like InstantSheller is preventing CPWizard from running upon startup.

So... can MaLa execute one program when it first starts up?  (eg. cpwizard.exe -minimized)

Are there any other alternatives for me?

Also, does anybody know how CPWizard is able to show itself when MAME gets paused?  (is it installing a keyboard hook in Windows and simply reads the MAME config file to figure out the pause key or does it interact with MAME itself somehow?)

Thanks for any help!

arzoo

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2093
  • Last login:January 26, 2025, 08:51:53 am
  • Robots WILL kill you.
    • LEDBlinky
Also, does anybody know how CPWizard is able to show itself when MAME gets paused?  (is it installing a keyboard hook in Windows and simply reads the MAME config file to figure out the pause key or does it interact with MAME itself somehow?)

Thanks for any help!

MAME provides output messages including 'pause'.
Robots will kill you.



Arcade Addiction

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2943
  • Last login:August 14, 2023, 02:00:48 am
  • 0x2b|~0x2b?
Yep as arzoo said I use Mame's output system to detect pause.

The problem of running CPWizard when the FE is set as shell has been brought up before and I believe the way to do it is to run CPWizard as a service. If you check out BYOAC's wiki utilities page there are a few programs that do this under Misc Tools (eg. RunAsSvc).

Let me know how you go.

sofakng

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 646
  • Last login:February 18, 2021, 04:19:21 pm
I'm actually a software developer myself so I'm interested in "geek" stuff like that.  I'll have to read more on MAME's output system.

Anyways, when I create the service for cpwizard.exe, I'll need to specify -minimized, right?  (otherwise it would launch the layout editor but it would always stay in the background? [just guessing...])

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2943
  • Last login:August 14, 2023, 02:00:48 am
  • 0x2b|~0x2b?
I'm actually a software developer myself so I'm interested in "geek" stuff like that.  I'll have to read more on MAME's output system.

Anyways, when I create the service for cpwizard.exe, I'll need to specify -minimized, right?  (otherwise it would launch the layout editor but it would always stay in the background? [just guessing...])

Yes your right you need the -minimized switch so it will go to the icon tray. Then you can just send it command line switches as usual after that. Well you don't actually need to send any command line switches for Mame as it detects the game running automatically using Mame's Output System, but for other emu's you need to send the game name.

Check out the Mame Interop SDK if your interested in Mame's ouput system. There are source code examples and a dll for reading Mame's output.

TheShanMan

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1912
  • Last login:October 22, 2024, 11:51:12 am
    • My Arcade (updated 1/30/13)
I just did this myself, and one extra thing you have to do after creating the service is set it to "interact with the desktop". Otherwise it won't work. So you need to go into your services (control panel->administrative tools->services), find the service you created, and on the properties page check the box that says "interact w/desktop".
My Collection: Mame cab, 38 dedicated vids, pin, skeeball, coin op air hockey table, Ice Cold Beer, Megatouch, 2 token machines, and payphone (VAPS, pics at Arcade Crusade)

Add Ambience to your mame cab setup

jasonbar

  • Trade Count: (+10)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2249
  • Last login:June 15, 2025, 06:31:31 pm
  • Dr. Inferno
    • The Infernolab
Great thread--very handy.  I was in the same boat: I've got my cab PC set to boot straight to MaLa as the shell.   :cheers:

CPWizard wasn't starting via the usual methods (selecting "Run on Startup" in CPWizard) or putting a shortcut in the Startup section of the Start Menu.

Thanks for the final post, ShanMan.  Even with your help, it took me a little while to find the checkbox.  For the other slow users like me, it's in:


Start Menu/Settings/Control Panel/Administrative Tools/Services

Then Right-Click on your CPWizard Service that you created.  (I used RunAsSvc & it was a breeze.)

Select Properties.

In the new box, flip over to the Log On tab & the checkbox is the 2nd item from the top.


Thanks,
-Jason

dungbeetle46

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 327
  • Last login:June 25, 2016, 07:27:47 pm
why not just install the malalauncher plugin
job done

jasonbar

  • Trade Count: (+10)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2249
  • Last login:June 15, 2025, 06:31:31 pm
  • Dr. Inferno
    • The Infernolab
Because I don't know what the Malalauncher plug in is!   ;D

Please elaborate a little bit.  I actually might need to go with this Malalauncher option, because I seem to not have focus on MaLa when I boot my PC & get to the menu.  I need to do a mouse-click before it will respond to keyboard input (though it does respond to mouse input right off the bat...).

Please tell me more!

Thanks,
-Jason

TheShanMan

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1912
  • Last login:October 22, 2024, 11:51:12 am
    • My Arcade (updated 1/30/13)
My Collection: Mame cab, 38 dedicated vids, pin, skeeball, coin op air hockey table, Ice Cold Beer, Megatouch, 2 token machines, and payphone (VAPS, pics at Arcade Crusade)

Add Ambience to your mame cab setup

jasonbar

  • Trade Count: (+10)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2249
  • Last login:June 15, 2025, 06:31:31 pm
  • Dr. Inferno
    • The Infernolab
Very neat.  I've installed it & set it up & have a handful of issues...   :-\


I put a CPWizard shortcut in the plugins\Launch directory.  In the shortcut's properties box, I have it set to run minimized.  When I double-click this icon, I get the CPWizard button to appear in the system tray.  Cool.

Problem #1: However, when I run MaLa for the 1st time upon bootup (when CPWizard isn't already running), CPWizard appears on top of MaLa, not minimized (not mazimized either, but in the "Restore" partial-full screen size mode.

If I exit MaLa & re-launch MaLa, CPWizard won't pop up on top of MaLa.

Problem #2: When I launch a game from MaLa, CPWizard also launches & "fights" with MAME.  I see alternate blinking CPWizard & MAME for about 5 seconds.  Then it sticks on one or the other until I quite MAME or dismiss CPWizard.  Sometimes my MaLa info window pops up & starts cycling too (very odd).  I do have the same key assigned to show/hide the info window in MaLa as I have assigned for "Show Key" & "Exit Key" in CPWizard.

I've tried enabling & disabling Use Control Panel Viewer from within MaLa, with the same effect.



Got any ideas on where to start debugging this?


Thanks,
-Jason

TheShanMan

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1912
  • Last login:October 22, 2024, 11:51:12 am
    • My Arcade (updated 1/30/13)
CPWizard has a command line switch for running in the background. I think it's "-minimized" IIRC. Now that you mention it, that may have been your problem when running as a service.
My Collection: Mame cab, 38 dedicated vids, pin, skeeball, coin op air hockey table, Ice Cold Beer, Megatouch, 2 token machines, and payphone (VAPS, pics at Arcade Crusade)

Add Ambience to your mame cab setup

jasonbar

  • Trade Count: (+10)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2249
  • Last login:June 15, 2025, 06:31:31 pm
  • Dr. Inferno
    • The Infernolab
Howdy-

You're too quick on the response--I troubleshot #2 already.   :D  As fate would have it, I happened to assign the keystroke "O" to be the show/hide of the info window in MaLa & to be the "Show Key" & "Exit Key" in CPWizard.

So, since I have "Skip Disclaimer" checked in CPWizard (because I have 1 or 2 games that use old builds of MAME & I can't get rid of the disclaimer), CPWizard kept sending O & K, which kept making CPWizard appear & disappear & the info window in MaLa appear & disappear.




However, this still leaves problem #1.

Yes, if you launch CPWizard with the command line, prompt, you use the -minimized switch.  However, I've been unable to figure out how to apply the -minimized switch to the shortcut that I placed in the Launch folder.  In the Shortcut tab of the Properties box, I selected "Minimized" from the "Run" pull-down, & that works great when launching the shortcut from Windows Explorer, but when MaLa launches that same shortcut through your plugin, it doesn't minimize...


Ideas?

Thank you very much,
-Jason

dungbeetle46

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 327
  • Last login:June 25, 2016, 07:27:47 pm
copy the following to notepad and then save as a .bat file and put this in the launch folder instead of cpwizard.exe
let me know how it goes

@echo off
path c:\program files\cpwizard
start cpwizard.exe /MIN

jasonbar

  • Trade Count: (+10)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2249
  • Last login:June 15, 2025, 06:31:31 pm
  • Dr. Inferno
    • The Infernolab
Very close, DungBeetle, thanks!!!

But not quite there...

I had to change the last line of the bat file:
@echo off
path c:\program files\cpwizard
start cpwizard.exe -minimized


The "/MIN" switch didn't work, but changing it to "-minimized" did make CPW truly start out minimized (I see a brief flicker as MaLa launches, so I know it's launching CPW).



Now, the catch is this: using this bat file & MaLaLauncher works perfectly if I click the MaLa icon on the Windows desktop to launch MaLa.  However, when I boot my PC & it jumps right into MaLa as its shell, I still have loss of focus (though CPW is indeed starting up nice & minimized).

So close!

Thanks,
-Jason

dungbeetle46

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 327
  • Last login:June 25, 2016, 07:27:47 pm
have you tried the focus logger plugin again by  :notworthy: shanman :notworthy: available on malafe.net

Stormrider

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 318
  • Last login:September 28, 2014, 11:01:54 am
I'll tell you the solution I found for a similar problem I had.

I have MaLa set to load on startup instead of explorer. hkey_local_machine\software\microsoft\windows nt\currentversion\winlogon -> Userinit Change C:\WINDOWS\system32\userinit.exe, with the path to your frontend .exe file, for instance: d:\mala\mala.exe. Now, you can configure the frontend to run explorer.exe on exit.

The problem I had was that I needed to run an exe file (script) before MaLa. The solution was to change the aformentioned reference in the registry with this: d:\mala\coindrop\coindrop.exe,d:\mala\mala.exe that is, the path to the script exe and then the frontend exe (separated by a comma). It works :)

TheShanMan

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1912
  • Last login:October 22, 2024, 11:51:12 am
    • My Arcade (updated 1/30/13)
Pretty cool, Stormrider! Who would have thought?

As for the shortcut for MaLaLauncher, "-minimized" is not the same thing as setting the shortcut to launch a program minimized. Actually, a program can totally ignore that setting, but in this case -minimized doesn't mean the same thing as the shortcut minimized option. The cpw option really tells it to HIDE the main window and just put an icon in the tray. If you do it that way I don't think you'll have any focus issues - at least not any caused by cpw.

BTW, you'd put -minimized after the target (exe) in the shortcut dialog.
My Collection: Mame cab, 38 dedicated vids, pin, skeeball, coin op air hockey table, Ice Cold Beer, Megatouch, 2 token machines, and payphone (VAPS, pics at Arcade Crusade)

Add Ambience to your mame cab setup

jasonbar

  • Trade Count: (+10)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2249
  • Last login:June 15, 2025, 06:31:31 pm
  • Dr. Inferno
    • The Infernolab
[begin epic saga odyssey verbose mode post]

Boy howdy, you've all got great suggestions & I've exhausted them all (and then some!) & not tuned this in.

The basic problem is this: MaLa loads quickly, while CPWizard loads slowly, so if I launch them simulataneously or near-simultaneously, then MaLa inevitably loads faster & when CPWizard finishes loading, it steals focus.

No combination of shell combo loads, MaLaLauncher, FocusLogger, etc worked for me.  (scroll to bottom of post for failure list).



So, I really just need to launch CPWizard, delay for x seconds, then launch MaLa.  That's the secret.

So, I changed the shell back to explorer, clicked "run on startup" in CPWizard to make sure it would launch ASAP, & made a bat file like this & put it in the Startup folder:


start /wait c:\windows\sleep.exe 40 /MIN

start c:\emulators\mala\mala.exe


sleep.exe is a little download I found after failing to get a ping-based delay to work right.  "40" is how many seconds I wait (need to trim that way down--have yet to optimize it).


This works fine.  Phew!



But!!!  There's one catch--after the Windows desktop loads, it pops up a command line window for the batch file & then another command line window while sleep.exe runs.  Pretty ugly.



After lots of searching around, I found a nifty app called cmdow: http://www.commandline.co.uk/cmdow/

It lets you tile windows, minimize windows, launch bats in a certain window state, etc. etc.

Alas, although I can pass arguments to the program being launched with cmdow, I can't seem to send it the command of start /wait & then a program name & its argument, so I can't have it run the sleep program, wait till the sleep program's over, and *then* launch MaLa.

So, I need TWO batch files & I still get 1 command line flicker for a brief instant when Windows loads.


The 2 magic batch files:

runmalasleep.bat is in my startup folder:
cmdow /run /hid c:\emulators\mala\malasleep.bat /ma
[the /ma is just for good meaure to minimize all windows at this point, even though there's no other window open...]

and malasleep.bat is as follows:
sleep.exe 4  [4 seconds turned out to be the magic number]
start c:\emulators\mala\mala.exe

[yes, I know, I don't have start /wait on the sleep.exe 4 command, but it works great--if I add start /wait before sleep.exe, then I get an extra window popping up.......and if I just try to run sleep.exe 4 via cmdow & then have the next line launch mala, it launches both simultaneously]


Oh wait, did I forget to mention  :banghead: :banghead: :banghead: :banghead: :banghead:?


Thanks,
-Jason




Appendix 1:

Here's what I tried & the failure results:

shell: mala + focuslogger & malalalauncher of cpw -> no focus

shell: cpwizard,mala + malalauncher of cpw -> works but CPW not minimized

shell: cpwizard -minimized,mala + malalauncher of cpw -> no focus

shell: cpwizard -minimized,mala + focuslogger & malalauncher of cpw -> no focus

shell: cpwizard -minimized,mala + focuslogger -> no focus

shell: explorer + mala & cpwizard in startup folder -> works but CPW not minimized

shell: explorer + mala & cpwizard bat in startup folder -> no focus

shell: explorer + mala & cpwizard bat in startup folder & focuslogger-> no focus

shell: explorer + mala/cpwizard combo bat in startup folder & focuslogger -> no focus

shell: explorer + mala/cpwizard combo bat in startup folder -> no focus

shell: explorer + mala in startup folder + cpwizard "run on startup" checked -> no focus

shell: explorer + mala "start with windows" checked + cpwizard "run on startup" checked -> no focus


try making bat file to launch cpwizard then mala, with a delay in between:

1 ping command didn't work

2 download sleep.exe -- success!!!

TheShanMan

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1912
  • Last login:October 22, 2024, 11:51:12 am
    • My Arcade (updated 1/30/13)
There really should be no focus issues with cpw... I didn't see any mention of trying my shortcut change using MaLaLauncher. That's how my mame cab is configured and there is no focus problem. -minimized will launch cpw hidden while using the shortcut's minimize option will only minimize it, leaving it visible and possibly stealing focus.
My Collection: Mame cab, 38 dedicated vids, pin, skeeball, coin op air hockey table, Ice Cold Beer, Megatouch, 2 token machines, and payphone (VAPS, pics at Arcade Crusade)

Add Ambience to your mame cab setup

jasonbar

  • Trade Count: (+10)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2249
  • Last login:June 15, 2025, 06:31:31 pm
  • Dr. Inferno
    • The Infernolab
Howdy Shan-

Thanks for the reply.  I did indeed try your MaLaLauncher & a CPW shortcut many times.  See the 1st 4 items in my list of attempts in my previous post.



Focus still gets stolen from MaLa when using MaLaLauncher to open the CPW shortcut w/ the -minimized switch.  Here's how it plays out:

1 I turn on my PC
2 Windows boots
3 MaLa appears
4 About 5-10 seconds later, a thin gray line of pixels appears across the bottom of my screen--it's my Windows toolbar, in auto-hide mode.  At this point, I know that focus is no longer with MaLa.


Thanks,
-Jason

TheShanMan

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1912
  • Last login:October 22, 2024, 11:51:12 am
    • My Arcade (updated 1/30/13)
Nothing you've said specifically mentions what I described as far as I could tell, so I didn't know if you actually tried exactly that (mala shell plus the switch instead of the shortcut option). If you see the task bar, then that means explorer.exe is running (either as your shell, or from something actually launching it). So that could be your problem. I have mala as my shell, and a malalauncher shortcut launching cpw and that works fine for me.
My Collection: Mame cab, 38 dedicated vids, pin, skeeball, coin op air hockey table, Ice Cold Beer, Megatouch, 2 token machines, and payphone (VAPS, pics at Arcade Crusade)

Add Ambience to your mame cab setup

jasonbar

  • Trade Count: (+10)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2249
  • Last login:June 15, 2025, 06:31:31 pm
  • Dr. Inferno
    • The Infernolab
Yup, I was a little terse w/ my list of failed attempts, & I doubted my memory, so I redid exactly what you proposed in your last post (with and without FocusLogger) & no luck.  MaLa didn't retain focus when it launched.  I didn't get the thin gray hidden task bar at the bottom of the screen, but the rest of the behavior was still identical to what I described before.

I went back to my crazy double bat file + 2 downloaded utilities & it's fine now... :dizzy:

Thanks,
-Jason

jasonbar

  • Trade Count: (+10)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2249
  • Last login:June 15, 2025, 06:31:31 pm
  • Dr. Inferno
    • The Infernolab
Effective solution for me achieved thanks to bkenobi & AutoHotKey.

http://forum.arcadecontrols.com/index.php?topic=97119.msg1027416#msg1027416

Thanks,
-Jason
« Last Edit: October 21, 2009, 01:16:20 am by jasonbar »