Jump to content
LaunchBox Community Forums

Recommended Posts

Posted

Reinstalled to a different drive, only way it works is to run the batch file as admin, it then closes down Lichtknarre.exe, dolphin loads but it then doesn't reload Lichtknarre.exe once dolphin is closed 🫣

Posted (edited)

Good Day Everyone. Wondering if i could get help on something. i wanted to create a script that checks to see if i have daemon tools running. if it isn't it launch it, then mount an iso/cue to a specific drive letter. (J)once launched  whenever i press the esc key i wanted to unmount it. i was gonna place this in the additional apps section. Im using daemon tools lite. could someone help me with this?

Daemon tools Location

C:\Program Files\DAEMON Tools Lite\dtagent.exe

Game location

D:\Roms\Microsoft DOS\Roms\Where in the World is Carmen Sandiego 1996\csworld96.iso (i wanted to mount to drive letter J)

Edited by Cnells2000
Posted
On 12/11/2024 at 2:02 PM, -neo- said:

Hi,

Can any of you AHK wizards show me how to close an already running program then load a emulator then reload the closed program, I've tried and then googled now my head hurts 🫣

Even did try a basic batch file i found online then altered the file paths and ran that outside of LB - 

taskkill /IM Lichtknarre.exe /F

Pause

start/wait "Dolphin" /B  "G:\LaunchBox\Emulators\Dolphin\Dolphin.exe" %1

Pause

start "Lichtknarre" /B "C:\Program Files\Lichtknarre\Lichtknarre.exe"

Pause

exit

but that give this error -

C:\Users\Retro-pc\Desktop>taskkill /IM Lichtknarre.exe /F
ERROR: The process "Lichtknarre.exe" with PID 8752 could not be terminated.
Reason: Access is denied.

Thanks in advance for any help :)

no idea what i'm doing but trial and error, got this AHK code to run outside of LB, how would i add that to the dolphin emulator, assume in the running script ? 

Process, Close, Lichtknarre.exe

runwait "G:\LaunchBox\Emulators\Dolphin\Dolphin.exe"

run "G:\LaunchBox\0-UTILS\Lichtknarre\Lichtknarre.exe - Shortcut.lnk"

Had to use the shorcut.lnk or it wouldn't load at all 🫣

Thanks in advance for any help or point me in the right direction :)

 

Posted
1 hour ago, -neo- said:

no idea what i'm doing but trial and error, got this AHK code to run outside of LB, how would i add that to the dolphin emulator, assume in the running script ? 

Process, Close, Lichtknarre.exe

runwait "G:\LaunchBox\Emulators\Dolphin\Dolphin.exe"

run "G:\LaunchBox\0-UTILS\Lichtknarre\Lichtknarre.exe - Shortcut.lnk"

Had to use the shorcut.lnk or it wouldn't load at all 🫣

Thanks in advance for any help or point me in the right direction :)

 

Correct. You'd add it to the Running Script.  But of course, you won't be starting ('RunWait') Dolphin as LaunchBox is already doing that.  What you're needing to do at that point is wait for Dolphin to be running and then wait for it to 'no longer exist' (aka, you exit the emulator).

Process, Close, Lichtknarre.exe

Process,Wait,Dolphin.exe
While WinExist("ahk_exe Dolphin.exe")
    Sleep 700

run "G:\LaunchBox\0-UTILS\Lichtknarre\Lichtknarre.exe - Shortcut.lnk"

 

A potential problem is, when you exit the emulator, the Running Script gets abandoned.  Possibly not allowing the last "run" to execute.  I don't know how fast it gets abandoned when the emulator closes.  As in, it may still execute the last Run line.  If you find it isn't restarting Lichtknarre.exe, you can try replacing the last "run" line with:

$Esc::
{
  run "G:\LaunchBox\0-UTILS\Lichtknarre\Lichtknarre.exe - Shortcut.lnk"
  WinClose, ahk_exe Dolphin.exe
}

 

  • Thanks 1
Posted
5 hours ago, Cnells2000 said:

Good Day Everyone. Wondering if i could get help on something. i wanted to create a script that checks to see if i have daemon tools running. if it isn't it launch it, then mount an iso/cue to a specific drive letter. (J)once launched  whenever i press the esc key i wanted to unmount it. i was gonna place this in the additional apps section. Im using daemon tools lite. could someone help me with this?

Daemon tools Location

C:\Program Files\DAEMON Tools Lite\dtagent.exe

Game location

D:\Roms\Microsoft DOS\Roms\Where in the World is Carmen Sandiego 1996\csworld96.iso (i wanted to mount to drive letter J)

 

I have no idea what the command line is to mount/unmount an ISO to a drive letter, so I'm going to pretend it's -mount, -unmount and -driveletter.

Process,Exist, dtagent.exe
If ( ErrorLevel = 0 ) 
{
   Run, "C:\Program Files\DAEMON Tools Lite\dtagent.exe" -mount "D:\Roms\Microsoft DOS\Roms\Where in the World is Carmen Sandiego 1996\csworld96.iso" -driveletter G
}

$Esc::
{
   Run, "C:\Program Files\DAEMON Tools Lite\dtagent.exe" -unmount "D:\Roms\Microsoft DOS\Roms\Where in the World is Carmen Sandiego 1996\csworld96.iso"
   Return
}

The 1st line looks for the process.  If the ErrorLevel (2nd line) = 0, then it's not running.

 

Once you figure out the correct command lines, change the 2 "Run" commands to those (i.e. something that actually works. ;) ).

  • Thanks 1
Posted (edited)
30 minutes ago, JoeViking245 said:

Correct. You'd add it to the Running Script.  But of course, you won't be starting ('RunWait') Dolphin as LaunchBox is already doing that.  What you're needing to do at that point is wait for Dolphin to be running and then wait for it to 'no longer exist' (aka, you exit the emulator).

Process, Close, Lichtknarre.exe

Process,Wait,Dolphin.exe
While WinExist("ahk_exe Dolphin.exe")
    Sleep 700

run "G:\LaunchBox\0-UTILS\Lichtknarre\Lichtknarre.exe - Shortcut.lnk"

 

A potential problem is, when you exit the emulator, the Running Script gets abandoned.  Possibly not allowing the last "run" to execute.  I don't know how fast it gets abandoned when the emulator closes.  As in, it may still execute the last Run line.  If you find it isn't restarting Lichtknarre.exe, you can try replacing the last "run" line with:

$Esc::
{
  run "G:\LaunchBox\0-UTILS\Lichtknarre\Lichtknarre.exe - Shortcut.lnk"
  WinClose, ahk_exe Dolphin.exe
}

 

Just tried this -

Process, Close, Lichtknarre.exe

Process,Wait,Dolphin.exe
While WinExist("ahk_exe Dolphin.exe")
    Sleep 700

$Esc::
{
  run "G:\LaunchBox\0-UTILS\Lichtknarre\Lichtknarre.exe - Shortcut.lnk"
  WinClose, ahk_exe Dolphin.exe
}

Sadly it doesn't close Lichtknarre.exe at the start, as a test i didn't have Lichtknarre.exe running then tried a game, all the rest works, just need to kill Lichtknarre.exe then we are good to go :)

Edited by -neo-
Posted
7 minutes ago, -neo- said:

Sadly it doesn't close Lichtknarre.exe at the start, as a test i didn't have Lichtknarre.exe running then tried a game, all the rest works

Process, Close is the most forceful way (in AHK) to 'kill' a program.  The fact that you got it working outside of LaunchBox is a bit disconcerting.

If Lichtknarre actually has some sub-process (multiple instances), you could try something like (replacing the 1st line):

Loop 10
{
   Process, Close, Lichtknarre.exe
   Process, Exist, Lichtknarre.exe
} 
Until not ErrorLevel

This will look for up to 10 instances (which is a bit overkill) of the app, closing each one, until none exist, or 10 loops have been reached.

If that doesn't work... not sure what to tell you.  Especially since you got it to work outside of LaunchBox.

  • Thanks 1
Posted
15 minutes ago, JoeViking245 said:

Process, Close is the most forceful way (in AHK) to 'kill' a program.  The fact that you got it working outside of LaunchBox is a bit disconcerting.

If Lichtknarre actually has some sub-process (multiple instances), you could try something like (replacing the 1st line):

Loop 10
{
   Process, Close, Lichtknarre.exe
   Process, Exist, Lichtknarre.exe
} 
Until not ErrorLevel

This will look for up to 10 instances (which is a bit overkill) of the app, closing each one, until none exist, or 10 loops have been reached.

If that doesn't work... not sure what to tell you.  Especially since you got it to work outside of LaunchBox.

Sadly the damn thing is still open 🤬

Thanks for all your help, time for a beer or 3 and forgot about it for a while 🤣

Posted (edited)
Process, Close, Lichtknarre.exe

Process,Wait,Dolphin.exe
While WinExist("ahk_exe Dolphin.exe")
    Sleep 700

$Esc::
{
  run "G:\LaunchBox\0-UTILS\Lichtknarre\Lichtknarre.exe - Shortcut.lnk"
  WinClose, ahk_exe Dolphin.exe
}

Got it to work with the above code, LB needs to be run as admin 😎

Now it's beer o'clock 🍻

Edited by -neo-
Posted
4 minutes ago, -neo- said:

Got it to work with the above code, LB needs to be run as admin

Glad that it works.

But running LaunchBox as Admin WILL mess other things up!  Don't do that.

Instead, create a new AHK script.  Save it to somewhere/something like 'G:\LaunchBox\0-UTILS\MyScripts\Kill-Lichtknarre.ahk`

full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
   try
   {
      if A_IsCompiled
         Run *RunAs "%A_ScriptFullPath%" /restart
      else
         Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
   }
   ExitApp
}

Process, Close, Lichtknarre.exe

The new script restarts itself if it's not in admin mode, into admin mode.  Then... as "admin", closes (kills) the app.

 

Then in your Running Script, change the 1st line to:

Run, G:\LaunchBox\0-UTILS\MyScripts\Kill-Lichtknarre.ahk

 

So, I had initially missed/glossed-over/ignored that fact that you were initially starting the app as Admin. Which makes sense as to why you need to close it as admin.  When you ran the script outside of LaunchBox, you were admin. Thus it worked.  Something [for me] to keep in mind for future. ;)

  • Thanks 1
Posted

Yeah I've already found out it messes things up running as Admin 🤣 was only a test on my old gaming pc, thanks for the code, will try it tomorrow if my head isn't too sore 🍻

Posted (edited)
19 hours ago, JoeViking245 said:

Glad that it works.

But running LaunchBox as Admin WILL mess other things up!  Don't do that.

Instead, create a new AHK script.  Save it to somewhere/something like 'G:\LaunchBox\0-UTILS\MyScripts\Kill-Lichtknarre.ahk`

full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
   try
   {
      if A_IsCompiled
         Run *RunAs "%A_ScriptFullPath%" /restart
      else
         Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
   }
   ExitApp
}

Process, Close, Lichtknarre.exe

The new script restarts itself if it's not in admin mode, into admin mode.  Then... as "admin", closes (kills) the app.

 

Then in your Running Script, change the 1st line to:

Run, G:\LaunchBox\0-UTILS\MyScripts\Kill-Lichtknarre.ahk

 

So, I had initially missed/glossed-over/ignored that fact that you were initially starting the app as Admin. Which makes sense as to why you need to close it as admin.  When you ran the script outside of LaunchBox, you were admin. Thus it worked.  Something [for me] to keep in mind for future. ;)

Thanks again for all your help, works perfectly 🫡

On a side note i did have to install autohotkey v1.1 along side v2 on my test pc to get the AHK file to load :)

Edited by -neo-
  • Game On 1
Posted
1 hour ago, -neo- said:

Thanks again for all your help, works perfectly 🫡

On a side note i did have to install autohotkey v1.1 along side v2 on my test pc to get the AHK file to load :)

Glad it works (finally. lol).

I stick with v1.x because that's what's integrated with LaunchBox.  v2 may have some enhancements over v1 (never bothered to look).  But in some cases, the structure is different between the 2 (as you discovered).  And (luckily) so far there hasn't been anything I need to do that can't be done in v1.x.

On a side-sidenote:  I use CodeQuickTester for all my testing (outside of LaunchBox).  It has a super small footprint (<100kb).  It does need AutoHotkey.exe to run.  You can have multiple 'copies' of it, each pointing to a different version of AutoHotkey.exe.  Or just point it to ../LaunchBox/ThirdParty/AutoHotkey/AutoHotkey.exe (i.e., you don't need to have AHK installed).

  • Thanks 1
  • 2 weeks later...
Posted

Sorry to be a pain 🫣

I can use my xBox 360 controller or ESC key to shut down all emulators but with Dolphin if i use the xBox controller it doesn't  reload Licktknarre but the escape key does, i've had a quick dabble but no go :( am sure it's an easy fix, help 🤣 

$Esc::
{
  run "G:\LaunchBox\0-UTILS\Lichtknarre\Lichtknarre.exe - Shortcut.lnk"
  WinClose, ahk_exe Dolphin.exe
}

 

Posted
44 minutes ago, -neo- said:

Sorry to be a pain 🫣

I can use my xBox 360 controller or ESC key to shut down all emulators but with Dolphin if i use the xBox controller it doesn't  reload Licktknarre but the escape key does, i've had a quick dabble but no go :( am sure it's an easy fix, help 🤣 

$Esc::
{
  run "G:\LaunchBox\0-UTILS\Lichtknarre\Lichtknarre.exe - Shortcut.lnk"
  WinClose, ahk_exe Dolphin.exe
}

 

Do all your other emulators use the same Escape hotkey sequence you show (restarting Lichtknarre)?

If so, is your Dolphin Default Command-line Parameters -b -e?

  • Thanks 1
Posted
On 12/24/2024 at 6:38 PM, JoeViking245 said:

Do all your other emulators use the same Escape hotkey sequence you show (restarting Lichtknarre)?

If so, is your Dolphin Default Command-line Parameters -b -e?

Only use the code for Dolphin as Lichtknarre plays nicely with the other emulators :)

yeah the Dolphin command-line parameters are -b -e

Merry Christmas BTW 🎅

Posted
1 hour ago, -neo- said:

Only use the code for Dolphin as Lichtknarre plays nicely with the other emulators :)

yeah the Dolphin command-line parameters are -b -e

You can add a hotkey to your existing script to get the controller to work.  Add it below your existing escape routine.

1Joy2::
   If GetkeyState("Joy1")
   SendLevel, 1
   Send {Esc}
Return

The above example uses a button combo.  Press and hold button 1 (aka "Joy1", aka "A"), then press button 2 (aka 1Joy2, aka "B").  (As written, it won't work the other way around.)  Setting SendLevel, 1 is required to be able to trigger the Escape sequence you already have in your code.

Change the 1 and 2 respectively to whatever buttons you want.

If you want to use only a single button press, remove the 2nd line.

🎄

  • Thanks 1
Posted

Thanks again for taking the time out from the festivities to clearly explain and help out this total AHK noob 🤣

i tried the below -

Run, C:\Users\Retro-pc\Desktop\LaunchBox\0-UTILS\0-myscripts\kill-Lichtknarre.ahk

Process,Wait,Dolphin.exe
While WinExist("ahk_exe Dolphin.exe")
    Sleep 700


$Esc::

2Joy5::
   If GetkeyState("Joy8") 
   SendLevel, 1
   Send {Esc}
Return

{
  run "C:\Users\Retro-pc\Desktop\Lichtknarre.exe - Shortcut.lnk"
  WinClose, ahk_exe Dolphin.exe
}


then i tried 

Run, C:\Users\Retro-pc\Desktop\LaunchBox\0-UTILS\0-myscripts\kill-Lichtknarre.ahk

Process,Wait,Dolphin.exe
While WinExist("ahk_exe Dolphin.exe")
    Sleep 700


$Esc::

{
  run "C:\Users\Retro-pc\Desktop\Lichtknarre.exe - Shortcut.lnk"
  WinClose, ahk_exe Dolphin.exe
}

2Joy5::
   If GetkeyState("Joy8") 
   SendLevel, 1
   Send {Esc}
Return

Had to run a AHK script to identify the xBox 360 controller, which turns out to be 2Joy and not 1Joy 🫣 sadly it doesn't close down the emulator BUT if I change {Esc} to !{F4} it does close it down but of course it doesn't reload Lichtknarre, clearly i'm doing something wrong and need more beer 🍻

Posted
23 minutes ago, -neo- said:

Had to run a AHK script to identify the xBox 360 controller, which turns out to be 2Joy and not 1Joy 🫣 sadly it doesn't close down the emulator BUT if I change {Esc} to !{F4} it does close it down but of course it doesn't reload Lichtknarre

Yeah, sending Alt+F4 will only close the emulator. And not trigger the Escape sequence you wrote.

try this

Run, C:\Users\Retro-pc\Desktop\LaunchBox\0-UTILS\0-myscripts\kill-Lichtknarre.ahk

Process,Wait,Dolphin.exe
While WinExist("ahk_exe Dolphin.exe")
   Sleep 700

$Esc::
{
   run "C:\Users\Retro-pc\Desktop\Lichtknarre.exe - Shortcut.lnk"
   WinClose, ahk_exe Dolphin.exe
}

2Joy5::
If GetkeyState("Joy8") 
{
   run "C:\Users\Retro-pc\Desktop\Lichtknarre.exe - Shortcut.lnk"
   WinClose, ahk_exe Dolphin.exe
}

 

  • Thanks 1

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...