LegzRwheelz Posted January 9, 2021 Share Posted January 9, 2021 11 hours ago, JoeViking245 said: "I think" this will work. Create a next Text file and then save (or rename) it as an AutoHotkey Script file. i.e. "F:\MyAHKs\GRwTrainer.ahk" Make sure the actual extension is getting changed to "ahk" from "txt"! The contents of the file will be something like this: #SingleInstance Force WinClose, ahk_exe Trainer.exe if WinExist("ahk_exe Ghostrunner-Win64-Shipping.exe") { WinActivate } else { Run, "F:\LaunchBox\Games\PC Games\Ghostrunner\Ghostrunner.exe" } Run, "F:\LaunchBox\Games\PC Games\Ghostrunner\Trainer.exe", , Min Sleep, 10000 Process, WaitClose, Ghostrunner-Win64-Shipping.exe WinClose, ahk_exe Trainer.exe Edit your GhostRunner game and set the Application Path to ThirdParty\AutoHotkey\AutoHotkey.exe ..and the Command Line Parameter to "F:\MyAHKs\GRwTrainer.ahk" With this, your launching the script instead of the game (which in turn will launch the game etc.). What the script does: Force the script to close if it's already running, and 'restart' it. Close "Trainer". (a simple 'catch' that doesn't hurt anything it it wasn't already running) Check if "Ghostrunner-Win64-Shipping.exe" is already running if it is { Bring its window to the top } otherwise { Run GhostRunner } Run Trainer minimized Wait 10 seconds for GR to [I assume this is what it does] spawn "Ghostrunner-Win64-Shipping.exe". It shouldn't take this long to 'spawn', but doesn't matter. He'll be 'playing' for at least 10 seconds anyway. Right? Hang out here until the game is exited. Once the game is no longer running, politely close Trainer. at this point, the script is done and will exit itself. No need to ExitApp. I think I caught from your description that Trainer and GR are independent of each other, in that one doesn't HAVE to be running PRIOR to the other. If that's not the case, this ain't gonna work as expected. If all goes well, you should be good to go. Not tested, but it "looks good on paper". Hey bud, thank you for replying with such great detail. Unfortunately, this wont work for me for a couple of reasons. (now I feel like a needy child again). 1.) I use RocketLauncher as my "Emulator" with LB/BB. 2.) Once it is working, I will be compiling the script to an EXE and leaving it in the same directory as GR. 3.) I also plan on pinning the compiled exe to the taskbar so my son can easily launch it when in the Desktop Env. You are correct in that they are both completely independent of each other. The reason for launching the trainer first is it will stay on top of GR and I want it to be fairly seamless. SO, I am fairly decent at understanding what is going on in a script when I am looking it over, I just am not good at knowing what to use and in what order (at times). I do refer to the AHK help website quite frequently, I just am unable to come up with the proper search term at times which leads me here or the AHK forums...sometimes, they're quite rude over there. Now, I did test the script and it is basically doing the same think my script did. It launches the trainer, then GH. However upon launch, it doesn't close the trainer if it is left running (It doesn't minimize either) and when closing GR, the trainer stays running. So, I originally changed the trainer's name to just trainer to simplify things. I figured maybe that could be causing this issue, so I deleted trainer.exe and extracted the trainer leaving it's original name (Ghostrunner v1.0 Plus 5 Trainer.exe) and tried a few different methods for closing the trainer. ie: using winclose with "Ghostrunner v1.0 Plus 5 Trainer ahk_class WindowsForms10.Window.8.app.0.297b065_r32_ad1", "ahk_exe Ghostrunner v1.0 Plus 5 Trainer.exe", as well as "process,close, Ghostrunner v1.0 Plus 5 Trainer.exe". Nothing is working. I have attached a screen shot of window spy for both GR and the trainer. Perhaps I am missing something entirely that is vital missing information for you assisting me. Again, thank you for you help @JoeViking245 1 Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted January 9, 2021 Share Posted January 9, 2021 Are either of your 2 programs being ran as admin? Try running the script as admin and see if that changes anything. Tear the script down piece by piece. i.e. To start: Have the script only close Trainer. Open Trainer then run the script. Double check syntax. i.e. my 2nd line didn't show quotes around ahk_exe Trainer.exe. (think I missed that one. Though off hand, not sure if they're actually required or not). Can you show what your script looks like? (btw the 2 picts were helpful). Myself, I cannot help you with anything about RocketLauncher. Not that I won't. It's just that I can't (never used it and have no plans to start. No offense. ) I'm off to bed and will check back in the morning. I expect a full report of your tests and findings. jk Hopefully the admin thing or breaking down the steps will help shed some light. 1 1 Quote Link to comment Share on other sites More sharing options...
LegzRwheelz Posted January 9, 2021 Share Posted January 9, 2021 (edited) I hope this helps others in search of a way to silently launch a trainer alongside their game and have the trainer close when the game closes. SO.....I have figured out it is the trainer that is at fault. Even a simple script to winactivate it does nothing. Changing it to winclose as well as process,close. something is fishy, I will check to see if it needs admin priv, I will report back.... 30 seconds later.... Well I'll be. I got help at the AHK forums and the script they helped me with works. It didn't work until I ran it as admin, like you suggested. Your script doesn't work for me in either instance, sadly.... however, your brilliant mind did help sort this out, so I tip my hat to you and say "thank you, kindly sir!" So at first I had a long drawn out explantion asking you what to add to run the launcher as admin and decided to do some digging on the ahk forums and found a few lines to launch it as admin (given the account I am on is the administrator account.) I also set the script to not show a tray icon, changed the absolute path that the guy who helped me over there set to a relative path so the script is protable as well as took your advice and removed the exitapp that he added. Here is the script I have: #NoTrayIcon #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #SingleInstance Force if not (RegExMatch(DllCall("GetCommandLine", "str"), " /restart(?!\S)")) { Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%",, UseErrorLevel ExitApp } if(A_IsAdmin) dir = %A_ScriptDir% tProc := "Ghostrunner v1.0 Plus 5 Trainer.exe", trainer := "ahk_exe " tproc gProc := "Ghostrunner-Win64-Shipping.exe", gr := "ahk_exe " gProc WinClose, %trainer% Sleep, 200 Run, %dir%\%tProc% WinWait, %trainer%,, 10 If ErrorLevel { MsgBox, 48, Error, An error occurred while waiting for trainer window. Return } WinMinimize Sleep, 2000 If !WinExist(gr) { Run, %dir%\Ghostrunner.exe WinWait, %gr%,, 10 If ErrorLevel { MsgBox, 48, Error, An error occurred while waiting for Ghostrunner window. Return } } Else WinActivate WinWaitClose WinClose, %trainer% What he initially helped me with looked like this: dir = F:\LaunchBox\Games\PC Games\Ghostrunner tProc := "Trainer.exe", trainer := "ahk_exe " tproc gProc := "Ghostrunner-Win64-Shipping.exe", gr := "ahk_exe " gProc WinClose, %trainer% Sleep, 200 Run, %dir%\%tProc% WinWait, %trainer%,, 10 If ErrorLevel { MsgBox, 48, Error, An error occurred while waiting for trainer window. Return } WinMinimize Sleep, 2000 If !WinExist(gr) { Run, %dir%\Ghostrunner.exe WinWait, %gr%,, 10 If ErrorLevel { MsgBox, 48, Error, An error occurred while waiting for Ghostrunner window. Return } } Else WinActivate WinWaitClose WinClose, %trainer% ExitApp Not much needed changing. Thank you once again. For your help, your brilliance, patience, and whether you realize it or not, you taught me to fish better than before. I hope you have a wonderful weekend. others Edited January 9, 2021 by CtinD Added A LOT of information 1 1 Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted January 9, 2021 Share Posted January 9, 2021 Glad you got it working! Pretty much all the info (tips, tricks and solutions) are out there. But finding the "correct" key word or phrase to search for can be frustrating. As you've found, a simple change in the lure, bait, line and even pole can make a big difference. As for 'trolling' to a different location, searching in Google will [most] always give you the best results over searching in a specific forum/site. So with the right gear in your tackle box, you too can "fish better than before." I know your son appreciates all your hard work too. "Game on!" 1 Quote Link to comment Share on other sites More sharing options...
Cnells2000 Posted January 9, 2021 Share Posted January 9, 2021 (edited) hi was trying to see if i could get help creating a batch file that once launched, waits 3 seconds closes example: peggle.exe, waits 2 seconds, launch angry birds.exe and only once angry birds is exited after finishing playing, wait 2 seconds and launch peggle.exe again batch file started wait 3 seconds fully Close peggle.exe wait 2 seconds launch D:Games/Rovio/angrybirds.exe wait till angry birds has exited naturally (as in not in task manager anymore) angry birds exited wait 2 secs launch D:/Games/Peggle/Peggle.exe Any help would be appreciated Edited January 9, 2021 by Cnells2000 Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted January 9, 2021 Share Posted January 9, 2021 Not sure how off hand to close an already opened program, but this should get you going on the rest rem batch file started rem wait 3 seconds timeout 3 rem not sure how to do this, so will comment out for now rem fully Close peggle.exe rem wait 2 seconds timeout 2 rem launch D:Games/Rovio/angrybirds.exe start /w "" "D:Games/Rovio/angrybirds.exe" rem wait till angry birds has exited naturally (as in not in task manager anymore) rem the /w in the previous command line "waits" until that program has exited before continuing rem wait 2 secs timeout 2 rem launch D:/Games/Peggle/Peggle.exe start "" "D:/Games/Peggle/Peggle.exe" Lines beginning with "rem" are 'remarks' (comments). Quote Link to comment Share on other sites More sharing options...
Cnells2000 Posted January 9, 2021 Share Posted January 9, 2021 (edited) 3 minutes ago, JoeViking245 said: Not sure how off hand to close an already opened program, but this should get you going on the rest rem batch file started rem wait 3 seconds timeout 3 rem not sure how to do this, so will comment out for now rem fully Close peggle.exe rem wait 2 seconds timeout 2 rem launch D:Games/Rovio/angrybirds.exe start /w "" "D:Games/Rovio/angrybirds.exe" rem wait till angry birds has exited naturally (as in not in task manager anymore) rem the /w in the previous command line "waits" until that program has exited before continuing rem wait 2 secs timeout 2 rem launch D:/Games/Peggle/Peggle.exe start "" "D:/Games/Peggle/Peggle.exe" Lines beginning with "rem" are 'remarks' (comments). so it keep the rem words right and just save the file as a .bat? because they dont hurt anything Edited January 9, 2021 by Cnells2000 Quote Link to comment Share on other sites More sharing options...
Cnells2000 Posted January 9, 2021 Share Posted January 9, 2021 and what would be a command line to fully kill a program? i could possibly just push windows key to get to batch file on desktop to start it to start the batch process Quote Link to comment Share on other sites More sharing options...
Cnells2000 Posted January 9, 2021 Share Posted January 9, 2021 Remark: batch file clicked timeout 2 Taskkill /F /IM "peggle.exe" /T timeout 2 start /w "" "D:Games/Rovio/angrybirds.exe" timeout 2 start "" "D:/Games/Peggle/Peggle.exe" @JoeViking245 would the taskkill command above be accurate to kill a program? i used the rest of your format Quote Link to comment Share on other sites More sharing options...
Cnells2000 Posted January 9, 2021 Share Posted January 9, 2021 timeout 2 taskkill /F /IM "peggle.exe" /T timeout 2 start /w "" "D:Games/Rovio/angrybirds.exe" timeout 2 start "" "D:/Games/Peggle/Peggle.exe" @JoeViking245 It seemed it worked to the letter but it did not wait until angry birds is exited before it started up peggle again. it just waited 2 seconds and then started peggle along side it so now they are both running simultaneously Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted January 9, 2021 Share Posted January 9, 2021 Sounds like angrybirds.exe is spawning another program that then [actually] runs (is) Angry Birds. So basically angrybirds.exe starts whatever.exe (which will be the actual game) and angrybirds.exe exits. Since "angrybirds.exe" has exited, the batch file continues on, while whatever.exe is still running. If my assumption is correct, you need to find out what 'whatever.exe' is and then account for it somehow. BTW, good find on the "taskkill" command. 1 Quote Link to comment Share on other sites More sharing options...
Cnells2000 Posted January 9, 2021 Share Posted January 9, 2021 this script doesnt make it wait either. it works the same though. damn, i thought this would be a simple task SETLOCAL EnableExtensions set EXE=angrybirds.exe Timeout 2 Taskkill /F /IM "peggle.exe" Timeout 2 Start "" D:Games/Rovio/angrybirds.exe :test FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq %EXE%"') DO IF %%x == %EXE% goto FOUND echo Not running Timeout 3 Start "" "D:/Games/Peggle/Peggle.exe" exit :FOUND echo Running goto test Quote Link to comment Share on other sites More sharing options...
Cnells2000 Posted January 10, 2021 Share Posted January 10, 2021 ok so for example big box has other processes that opens up with it so if i wanted to i could SETLOCAL EnableExtensions set EXE=bigbox.exe Timeout 2 Taskkill /F /IM "popcapgame1.exe" Timeout 2 Start "" D:Launchbox/Bigbox.exe :test FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq %EXE%"') DO IF %%x == %EXE% goto FOUND echo Not running Timeout 3 Start "" "D:\Roms\Popcap\Peggle Deluxe\peggle.exe" exit :FOUND echo Running goto test so if i wanted it to return to big box what other processes does big box have for example that i would have to wait for? i see 4 extra processes start but they aren't singled out so how would i know? see how it started peggle 2 seconds after big box began to begin loading? i want it to wait till big box has opened and once fully done and ive exited, then start peggle again bandicam 2021-01-09 19-45-00-276.mp4 Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted January 10, 2021 Share Posted January 10, 2021 Ya, I kinda tried that too (but with LaunchBox). Potential 'problem' here is "BigBox.exe" spawns "BigBox.exe". Same name. That may muddle things up. Not sure though. Maybe look through your D:\Games\Rovio folder(s) for another Application File that anrgybirds.exe might spawn. See if you can start AB's directly from this 'other file'. I know. I'm kind of reaching here. If you have AutoHotKey, you could run "WindowSpy". Or do like you did with BB and look at Process Explorer when AB is running and see if it's a different executable than angrybirds.exe. Ya, ya. Still reaching. 2 Quote Link to comment Share on other sites More sharing options...
Cnells2000 Posted January 10, 2021 Share Posted January 10, 2021 thank you for helping me get this far sir. angry birds is actually bigbox and peggle is another program that i did'nt talk about because i did'nt want to disrespect the forum in any way. but it works exactly the same and is the same concept and reacts the same. Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted January 10, 2021 Share Posted January 10, 2021 Oh well heck! lol. Go back to one of our earlier 'attempts' and try start /w "" "D:/LaunchBox/Core/BigBox.exe" That WILL truly wait for BigBox to exit before continuing the batch file. Guaranteed!! 1 Quote Link to comment Share on other sites More sharing options...
Cnells2000 Posted January 10, 2021 Share Posted January 10, 2021 9 minutes ago, JoeViking245 said: Oh well heck! lol. Go back to one of our earlier 'attempts' and try start /w "" "D:/LaunchBox/Core/BigBox.exe" That WILL truly wait for BigBox to exit before continuing the batch file. Guaranteed!! Like this? timeout 3 taskkill /F /IM "program.exe" /T timeout 2 start /wait "" "D:\Launchbox\bigbox.exe" timeout 2 start /w "" "D:/LaunchBox/Core/BigBox.exe" timeout 2 start "" "D:/program\program.exe" Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted January 10, 2021 Share Posted January 10, 2021 timeout 3 taskkill /F /IM "program.exe" /T timeout 2 start /w "" "D:/LaunchBox/Core/BigBox.exe" timeout 2 start "" "D:/program/program.exe" 1 Quote Link to comment Share on other sites More sharing options...
Cnells2000 Posted January 10, 2021 Share Posted January 10, 2021 (edited) ok that worked perfectly!!! but only by double clicking the .bat. Crap! when i run the app through the media center program the screen blinks and my taskbar dissapears. and all i see is my desktop with no taskbar. but it forces me to ctrl alt delete and sign out.... but if i minimize the window of the media center program and manually dbl click on the .bat your script works to the letter!! what do u think i could do here to remedy this? Edited January 10, 2021 by Cnells2000 Quote Link to comment Share on other sites More sharing options...
JoeViking245 Posted January 10, 2021 Share Posted January 10, 2021 21 minutes ago, Cnells2000 said: ok that worked perfectly!!! but only by double clicking the .bat ??? That's how I'd start it. Are you saying you have a 'shortcut' (of sorts) in your media center to run the batch file? And by running it that way, it's making the taskbar disappear? If you're running the batch file, BigBox will make the taskbar 'disappear'. I guess I'm not following what you're saying. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.