Jump to content
LaunchBox Community Forums

Assigning Hotkeys to start additional apps for specific games


nietzsche666

Recommended Posts

I'm looking for a completely easy way to swap isos for certain old windows games within launchbox. (So no emulator involved here).

As an example, I did a setup of a (flawed) old adventure game called "Necronomicon" as Windows game in Launchbox.

I programmed Launchbox to start that game automatically with CD1 mounted (DaemonTools Lite). I added a further additional app

for "Mount CD2" in Launchbox's game entry. When the game wants me to swap the iso file, I can get back to Launchbox environment and start my "Mount CD2" add. app.

This works perfectly well so far.

But it would be even easier still, if I could just program Launchbox to start my "Mount CD2" additional app without even leaving the game screen by using a hotkey, say the "*" - key from the numpad.

 

Is this possible right now at the moment, maybe by setting up an autohotkey-script?

Link to comment
Share on other sites

  • 2 weeks later...

Sorry for bringing this up again, but I'd really be grateful if anyone could enlighten a noob like me about this, as this matter is still unclear to me.

I'd Just like this question answered:

The feature I was talking about isn't possible at the moment, right? I'm not stupidly missing something obvious here?

Link to comment
Share on other sites

Im not sure if this is going to work correctly. I dont know if im understanding your Mount cd 2 app. Is it an additional app or just mounting another iso? I dont think launchbox has what your looking for but you can try the following... 

 

Download and install autohotkey.

Rightclick anywhere (lets say desktop)  - New - Autohotkey script (rename it to anything you want)

Rightclick on the new script - edit script

Copy and paste the following  (dont delete the lines already there):

#SingleInstance, Force
#Persistent
SetTitleMatchMode, 2
DetectHiddenWindows, On
 
SetTimer, ProcessCheckTimer, 3000
Return
 
ProcessCheckTimer:
Process, Exist, Game.exe
pid1 := ErrorLevel
If (!pid1)
         {
         ExitApp
         }
Return

NumpadMult:: Goto MountCD2

MountCD2:
{
Keywait, NumpadMult
Run Path-to-your-mount-cd2-app
Exitapp
}
Return

Your going to have to modify this a little.

Where it says "Game.exe", you need to change it to whatever your game process name is. Example: Necronomicon.exe

Where it says "Path-to-your-mount-cd2-app", change that to your Mount CD 2 app path or your iso path. Example C:\Users\username\desktop\etc

 

Save it.

Right click on it and compile script.

In Launchbox add the compiled script to the additional apps of the game. Select the "Automatically run after main application" box.

 

What this script does is every 3 seconds it will check to see if the game is running. If the games isnt running it will exit the script. If you don't do this then the script will continue to run in the background after you have closed the game. 

From "NumpadMult" (which I think is the numpad star key) down. It waits for you to press and release the key (If im not mistaken), this way it doesn't send multiple presses (I think). Then runs your Mount CD 2 app. Then closes the script.

 

If you have any problems let me know.

Link to comment
Share on other sites

Thanks a lot for the reply.

"Mount CD2" is just my name for the Launchbox-internal additional app feature for mounting the second iso file of that game. It is set up with DTAgent and this command line: -mount dt, "D:\Necronomicon\NEC_AL_2.ccd" right now. And, as I said before, I'd like to start that one with a custom hotkey.

 

 I'll try your method later tonight or tomorrow. Very nice of you, thanks again!

Edited by nietzsche666
Link to comment
Share on other sites

Ok so you put that command line in the "Application command line parameters" box in addition apps within launchbox?

 

If thats the case your going to have to do something else first. Create a batch file to unmount and mount iso. I kept getting syntax errors using autohotkey but batch file works fine.

 

To make this simpler I  suggest putting these files (batch file and autohotkey script) in your D:/Necronomicon folder.

Open D:/Necronomicon folder.

Right click anywhere.

New.

Text document.

Copy and paste the following:

cd "C:\Programs Files\DAEMON Tools Lite"
DTAgent.exe -unmount dt, 0
DTAgent.exe -mount dt, 0, "D:\Necronomicon\NEC_AL_2.ccd"

In this above, the 0 (zero) is your virtual drive number. So 0 would be your first virtual drive. Necronomicon cd1 will need to be mounted to the first drive for this to work.

File - save as - name it MountCD2.bat - save

Right click on MountCD2.bat - create shortcut 

Right click on shortcut - properties -  change "Run:" to "Minimised"

 

Now you can do the autohotkey script. 

For the path-to-run-your-mountcd2-app, put D:\Necronomicon\MountCD2 - Shortcut.lnk

 

Edited by jayjay
Link to comment
Share on other sites

"Ok so you put that command line in the "Application command line parameters" box in addition apps within launchbox? "

Yes, exactly. In the Additional Apps section of my game entry of Necronomicon.

 

I'll write feedback here as soon as I have the time to have a try at your method.

Edited by nietzsche666
Link to comment
Share on other sites

So, I finally got around at trying this. So far, it doesn't yet work exactly as it should. Some basic things already work quite well, though:

My compiled autohotkey-script "NecroMount2.exe" gets started automatically as additional app with the game from launchbox and can be seen running in my taskbar while the game is active and I change to Windows screen.

It ceases to be active after executing MOUNTCD2BAT, as expected. Pressing "*" starts the MOUNTCDBAT.lnk command, as wished. MOUNTCDBAT.lnk can be started minimized and generally changes CD1 to CD2 when I start it from desktop.

Right now, I can't execute it when the game is active as the MOUNTCD2BAT gives me "close running instances of virtual drives" errors. But I think this should cease when I'm at a point in the game when it wants me to swap isos. I'm not quite there, yet, though.

BUT, right now pressing the "*" key only works if I get out of the game screen to the desktop. As long as I'm in game environment, "*" gets ignored. This way, setting the hotkey isn't that much easier, if I have to alt-tab myself out of the game, it would be just as easy to start the old additional app from launchbox and alt-tab my way back. Hmm, is there a modification of the AHK-scrip possible that makes the hotkey active with the game screen running as active surface?

 

When I think about it, for these old WIndows games cases, setting up several hotkeys for each iso could be useful, AFAIR there is also "EVIL DEAD - HAIL TO THE KING" that needs to be run from isos  (i.e. doesn't have a complete harddisk install option). I think you had to change to CD2 and again back to CD1 later in the game. So it would be even better if AHK stays active as long as the game is running and gets setup with two action keys, say "*" for Disk 2 and "-" (Keypad) for re-changing to Disk 1.

 

 

 

 

Link to comment
Share on other sites

I made a mistake. In the additional apps settings you want to select the box that says "automatically run before main application". It should run after that. I dont have a numpad so I cant test the key. But if it still doesnt work after changing the additional apps setting try changing the * key in the script, change the two "NumpadMult" to Ctrl.

 

Iv been testing it and find I get kicked back to desktop. So I managed after a long while to edit the script a little to stop it happening, if you get kicked back try this:

 

#SingleInstance, Force
#Persistent
SetTitleMatchMode, 2
DetectHiddenWindows, On
 
SetTimer, ProcessCheckTimer, 3000
Return
 
ProcessCheckTimer:
Process, Exist, Necrono.exe
pid1 := ErrorLevel
If (!pid1)
         {
         ExitApp
         }
Return

NumpadMult:: Goto MountCD2

MountCD2:
{
Keywait, NumpadMult
Run, MountCD2.bat,,Hide
Exitapp
}
Return

This doesnt use the MountCD2 shortcut. Also I had to disable the auto play prompt in control panel. There is still flickering when the disk is swapped but it wont kick you out to desktop, I couldn't find a way to stop the flickering using DTlite. But using WinCDEmu works well, no flickering, smooth swap. But requires a bit more work.

 

Edited by jayjay
Link to comment
Share on other sites

Tried the new script and the "start automatically before" add. app setting, but it didn't really change anything about the problem described. The "*" - Numpad key is working fine. I can see it closing the autohotkey icon in my taskbar. But I still have to get back to windows environment for it to work. When I press "*" while in game, nothing happens and the icon is still there afterwards. Changing the hotkey to Ctrl didn't have an effect on this either.

 

The AHK script does work. It sets up "*" to start the batch file just fine. But the hotkey gets ignored as long as I'm within game environment.

 

 

Link to comment
Share on other sites

I actually set up my own AHK script by now for permanent Iso swap option as I described above, using numpad - "-" for Disc 1 and numpad -"*" for Disc 2. Of course, I had to write another batch file for mounting Disc 1. It works beautifully, if I could just figure out how to make my PC react to the hotkeys whilst in game environment:

 

 

#SingleInstance, Force
#Persistent
SetTitleMatchMode, 2
DetectHiddenWindows, On
 
SetTimer, ProcessCheckTimer, 3000
Return
 
ProcessCheckTimer:
Process, Exist, necrono.exe
pid1 := ErrorLevel
If (!pid1)
         {
         ExitApp
         }
Return


NumpadSub:: Goto MountCD1

MountCD1:
{
Keywait, NumpadSub
Run "D:\TORRENTDOWN II\Necronomicon\mountcd1.bat",,Hide
}
Return

NumpadMult:: Goto MountCD2

MountCD2:
{
Keywait, NumpadMult
Run "D:\TORRENTDOWN II\Necronomicon\mountcd2.bat",,Hide
}
Return

 

 

Link to comment
Share on other sites

Try running the script as Admin. You will get the prompt but just see if it works.

 

In your script you dont have the exitapp so it wont exit until the game is closed. Have you checked the virtual drive to see if cd1 is still mounted after swap.

 

To see if AHK does work while in game what I do is. Put a .png at c:\pic.png.

New script, just the 1 line:

Alt::run, c:\pic.png

 

I use alt because some keys can be disabled in some games. Run that along side the game and see if the picture opens. If not then its likely an admin thing, if yes then at least it narrows it down.

Edited by jayjay
Link to comment
Share on other sites

Thanks to someone named Noesis over at the AHK forums, he/she pointed out I was missing one character in the command for daemon tools. So now the following script will swap without the need for the .bat files, this works for me:

 

SetWorkingDir C:\Program Files\DAEMON Tools Lite
#SingleInstance, Force
#Persistent
SetTitleMatchMode, 2
DetectHiddenWindows, On
 
SetTimer, ProcessCheckTimer, 3000
Return
 
ProcessCheckTimer:
Process, Exist, necrono.exe
pid1 := ErrorLevel
If (!pid1)
         {
	 Run, DTAgent.exe -unmount F
         ExitApp
         }
Return


Alt:: Goto MountCD1

MountCD1:
{
Keywait, Alt
Run, DTAgent.exe -unmount F,,Hide
Sleep, 1000
Run, DTAgent.exe -mount_to F`, "C:\Necronomicon.iso",,Hide
}
Return

Ctrl:: Goto MountCD2

MountCD2:
{
Keywait, Ctrl
Run, DTAgent.exe -unmount F,,Hide
Sleep, 1000
Run, DTAgent.exe -mount_to F`, "C:\Necronomicon2.iso",,Hide
}
Return

 

For me -mount F and -unmount F, is to mount and unmount F drive so change all of those for whatever you need. Obviously you'll need to change "C:\Necronomicon.iso" to whatever your path is. And it will also unmount when game has exit. I still get flickering when swapping though.

Edited by jayjay
Link to comment
Share on other sites

If I set the compiled script to admin, it does react to the hotkey whilst in game! What happens now: The game gets minimized for the dtagent execution, sometimes it re-maximizes itself or it stays minimized. But the admin setting definitely makes the hotkey work within the game. If I could bring it to just "flicker" whle changing disk without leaving game screen, I'd be fine with the AHK script.

 

I'll test your new script tomorrow, when I got some minutes to spare again.  (Thanks for taking the time, much appreciated).

 

EDIT: Same goes for your pic.png "test". If the compiled script is set to admin, game minimizes and the pic gets opened. WIthout admin settings, it doesn't react within game environment.

Edited by nietzsche666
More Info
Link to comment
Share on other sites

Good its working. EDIT. Im assuming you get the run as admin prompt when the script launches. I haven't successfully got around that problem.  The only thing I have found that stops the prompt is to turn off the UAC in windows. I have turned it off on my pc but its always offline so no big deal. But it isnt recommended to turn it off. Also when you get the prompt nothing else works, so you cant have another script to auto ok it. 

 

A long shot, but make sure the game isn't being run as admin in properties. If its not then it prob  runs in admin automatically and not a lot you can do.

 

What about trying to run it with the game in windowed mode or borderless window. I remember playing around with it, cant really recall the results apart from not being to happy with the window.

 

I tried to get the game to behave but even with some WinActivate or WinRestore commands it would still sometimes stay minimised. I'll be using WinCDEmu instead of daemon tools for aesthetic reasons. No going back to desktop or flickering, all happens behind the scenes. I'll put a tutorial here, if you or anyone else wants to use it or not is entirely your choice.

 

I'll use Necronomicon as the example and assume its already imported into launchbox.

Step 1:

Google, download and install WinCDEmu. Its free and can be installed along side daemon tools. It might change file association but changing it back to daemon tools isn't a problem. To remove a virtual drive using WinCDEmu just right click on the drive and eject.

 

Once installed go to C:\Program Files\WinCDEmu and open vmnt.exe

Select "Prefer drive letters starting with" and choose v: (you can choose any drive, just modify any scripts to match it, I'll be using v:)

Leave everything else blank... ok

 

Step 2: Launchbox + Necronomicon settings

 

Option 1 (with "insert cd1" nag): 

In Launchbox, find Necronomicon, edit, Additional apps, add application

Give any name.

Application path is C:\Program Files\WinCDEmu\batchmnt.exe

Application command line parameters: "path to cd1.iso" v: 

Check "automatically run before main application" box

 

Option 2 (no "insert cd1" nag)

Create a new script:

#SingleInstance Force
SetWorkingDir C:\Program Files\WinCDEmu

Run, batchmnt.exe "path to cd1.iso" v: /wait
Sleep, 1000
Run, "path to Necronomicon.exe"

For me the "path to Necronomicon.exe" is C:\Program files\Necronomicon\Necrono.exe.

Change path to cd 1.iso

File - save as- anything you want.ahk

You can compile it or not, save it in any directory but probably best in with the iso's.

In launchbox, find Necronomicon, go to settings and under the Launcher tab. Change Application path to the new script. (you might get a nag about root folder, I always leave it blank, it seems to works)

 

Test to make sure the game loads up ok.

(if you know of a better way to launch the game with no cd1 nag please let me know)

 

Step 3 - 

create a new script

SetWorkingDir C:\Program Files\WinCDEmu
#SingleInstance, Force
#Persistent
SetTitleMatchMode, 2
 
SetTimer, ProcessCheckTimer, 3000
Return
 
ProcessCheckTimer:
Process, Exist, GAME.exe
pid1 := ErrorLevel
If (!pid1)
         {
	 Run, batchmnt.exe /unmount v:,, Hide
         ExitApp
         }
Return

Ctrl::Goto MountCD1
Alt:: Goto MountCD2

MountCD1:
{
Keywait, Ctrl
Run, batchmnt.exe /unmount v:,, Hide
Sleep, 1000
Run, batchmnt.exe "path to cd1.iso" v: /wait,,Hide
}
Return

MountCD2:
{
Keywait, Alt
Run, batchmnt.exe /unmount v:,, Hide
Sleep, 1000
Run, batchmnt.exe "path to cd2.iso" v: /wait,,Hide
}
Return

In the script change GAME.exe to game process name

change path to cd1.iso and cd2.iso

If you want to change the keys pressed then change the 2 instances of Alt or Ctrl.

Compile it or not, store it where ever.

In Launchbox, Necronomicon, additional apps.

Give it any name.

Point application path to the script.

Run before main application.

Done.

 

 

Edited by jayjay
  • Like 1
Link to comment
Share on other sites

" Im assuming you get the run as admin prompt when the script launches. ´"

Actually no, I don't get any prompt you are talking about. Maybe my Win10 is set up differently, I played around with the settings a lot since I installed it some years ago. The only problem at MY system with the admin-set compiled script is that it doesn't execute the hotkey commands without minimizing/leaving the game screen.

 

I'll have a look at the WinCDEmu method this weekend and write about the experiences later here in the thread..

Edited by nietzsche666
spelling
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Ok, sorry for the long break before my reply. I got into work trouble last week and subsequently lost track of this little thread. My bad!

But the good news is: YES, method works as it should, exactly as I imagined it before. I just tried Option 2 without "Insert CD1 nag". I don't see anything too complicated about writing up two text files, so I didn't bother with option 1 at all.

Script files + Instructions are perfect. One thing I still had to find out and do by myself: I still had to compile the second AHK Script for the swapping setup and set it to "run as admin". Otherwise, it doesn't recognize the hotkeys within the game. I think it has to be compiled for the admin setting, but I'm actually not sure about this.  But with this method and admin setting, nothing gets minimzed and no "flickering" or anything. It just changes the isos in the background as wished.

For some reason, WinCDEmu fortunately behaves quite differently than Daemon Tools Lite. With WinCDEmu method, the "Close all running applications" lock gets overridden and I can swap the isos at any time. (Game will of course crash, if it's not the right moment for that and it still needs the other disk, but that is just obvious and expected.)

I get the WIN10 "mount/unmount drives" info sounds with the WinCDEmu method at the start, end and when swapping the isos. This might annoy others, but I'm happy with it like this, as I know the Ahk-Script worked and the isos were actually swapped.

 

I have a slight problem that in about 1 of 10 cases of starting the game, the first script messes up and doesn't get to load the first iso. I know this problem from working with Daemon Tools and Launchbox additional apps in other games. Sometimes the mount process takes too long and the game subsequently crashes. I usually just check the "wait for exit" box for the "Mount Disk 1" additional app. This method won't work here, of course. But it seldom happens, and so I'm hardly bothered by this.

 

 

I'd recommend posting the fine AHK Script files for WinCDEmu-Swap-method for other users in the Hotkey-Script - Threads. I think by now the thread title here is somewhat misleading. It should be posted as something like "Hotkey-Script for easy ISO-Swap for old Windows Games", so others having trouble with similar cases don't have any troubles finding this method when browsing the LB forums.

Link to comment
Share on other sites

I just found out the secret about the problem with the "admin" mod. My necrono.exe was set on WIn98 compatibility mode. I must have played around with it at some point and forgot about it. It is indeed a very old game, but WIN98 compatibility is not even necessary, game exe works fine without compatibility setting. If compatibility mode is not set, there is no need for setting the AHK script to "admin" for making the hotkeys work in game environment.
 

But that could still pose a problem if a game actually needs compatibility modes to run.

Edited by nietzsche666
clearer
Link to comment
Share on other sites

Good its working well.

 

For the iso's that take to long to mount before the game loads try this as "option2" script:

#SingleInstance Force
SetWorkingDir C:\Program Files\WinCDEmu

Run, batchment.exe "path to cd1.iso" v: /wait

DriveGet:
{
	Loop
		{
	DriveGet,DVDL,Label, v:
	If Errorlevel <> 0
		{
		Continue
		}
	Else
		{
		Run, "path to Necronomicon.exe"
		Exitapp
		}
		}
}

 

This will keep looping round checking v: drive. Once it finds a mounted image it will then load the game. Should hopefully stop the issue.

Edited by jayjay
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...