Hey all, I'm back with an issue that most likely has a simple solution as most of my ahk issues seem to entail.
I hope I am not being difficult and that this fix is simple enough.
I am attempting to create a launcher for launching a trainer alongside GR (Ghostrunner) so my son (who's 6) can play this hard as nails game with ease and when GR's process closes, the trainer closes along with it. I need to prevent the trainer from launching multiple times as well as GR. I have the part figured out for the game already, as you can see. I tend to have difficulties laying things out simply and/or clearly when I am trying to convey what I intend to or need to accomplish, so...Just to clarify on what I am needing to accomplish:
1. Upon launching the script, The script checks to see if trainer.exe is already running (to avoid multiple instances of it running), if not then launch it (minimized preferably). If it is running, then close and reopen it (to ensure the trainer's settings are cleared). Once it is running, the script waits 2 seconds before proceeding to launching GR. If the trainer can be launched minimized, then the order of launching isn't important. As of now, the trainer needs to launch first because it launches on top of GR.
2. GR is then loaded, if GR is already running and the launcher is ran again or clicked too many times, it uses winactivate to bring the game's window to the forefront (i prefer to use ("ahk_exe Ghostrunner-Win64-Shipping.exe") over the window title) as the window it looks for.
3. Next it waits for the ghostrunner window to close as it's cue to close the trainer
4. close the script when both Ghostrunner and the trainer is closed. (exitapp)
I imagine that some of these steps are redundant. I am far from proficient in AHK though. Hopefully all of this makes sense. Here is what I've come up with so far....
Code: Select all
if WinExist("ahk_exe Ghostrunner-Win64-Shipping.exe")
{
WinActivate
}
else
Run "F:\LaunchBox\Games\PC Games\Ghostrunner\Trainer.exe", 2
Run "F:\LaunchBox\Games\PC Games\Ghostrunner\Ghostrunner.exe"
Process, Wait, Ghostrunner-Win64-Shipping.exe, 10 ;max 10 sec.
Process, WaitClose, Ghostrunner-Win64-Shipping.exe
Process, Wait, Trainer.exe
Process, WaitClose, Trainer.exe
return
exitapp
As you can tell, it is not doing what I am intending for it to do.
Thank you in advance. I feel like a needy child. lol
Last, but most certainly not least...I would like to say thanks to all of you for all the help you selflessly provide to others. Be it here or IRL.