Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Ask gaming related questions
User avatar
rommmcek
Posts: 1190
Joined: 15 Aug 2014, 15:18

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

25 Sep 2020, 11:11

tobsto occupied wrote:
24 Sep 2020, 05:37
btw another question how do i make it so my batch exits everything not just if my game exits but if i get an werfault error while the game is still running i wonder
- Fist you assign to the variable "process_name" value "ACM.exe". Then you assign to the same variable value "Werfault.exe". As a result "ACM.exe" is being overwritten by "Werfault.exe". So if you need the value "ACM.exe" later below in the script you don't have it any more!
- The only condition in the script is: If there is %process_name% (in your case "Werfault.exe") in the tasklist then Goto lable :RUNNING. So the script repeats that loop as long "Werfault.exe" process is running.
When "Werfault.exe" process is not running anymore the script will kill "cheatengine-x86_64.exe" , "Texmod.exe" and "Texmod and Game Autolauncher.exe". It will attempt to kill "Werfault.exe" too, but it obviously doesn't exist anymore...

Now on "Werfault.exe" error the process probably doesn't exit by itself (it means the script will loop further on) and that's probably why it doesn't work.
To detect error of the "Werfault.exe" you can monitor e.g. (CPU usage, Memory usage, GPU usage, eventual messages from "Werfault.exe" if any, etc...). Actually how do you know by yourself when "Werfault.exe" has an error?
User avatar
rommmcek
Posts: 1190
Joined: 15 Aug 2014, 15:18

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

25 Sep 2020, 11:12

GPU script: I didn't saw, you've set a good condition (if %z% Lss 20). However the value of the z variable is empty. You have to grab z value with the script we developed which yields something like 41, 52, 0, 4874, 11264, 66. Go on you're so close!
User avatar
tobsto occupied
Posts: 148
Joined: 20 Feb 2020, 09:34
GitHub: washingleavesandthen

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

25 Sep 2020, 13:53

rommmcek wrote:
25 Sep 2020, 11:09
tobsto occupied wrote:
23 Sep 2020, 17:19
...
… guess Doom 2016 is just special like that lols, must be some protection of sorts of its Engine , here is what it looks like>
I think, I recognize the behavior. Some user interfaces (Gui-s, menu-s etc.) generated by browser sometimes doesn't respond to the running ahk script. I use auxiliary ahk script as a workaround. In your case it suffice a simple relaunch of the ahk script. So you did a great observation! The only issue could be if the first launch doesn't exit by itself then you have after the second launch two scripts running. If so, you can avoid this issue by adding to the script #SingleInstance, Force.
yeah my script is indeed set to autoexit once finished running as you can see in my previous post concerning this reply 8-)
User avatar
tobsto occupied
Posts: 148
Joined: 20 Feb 2020, 09:34
GitHub: washingleavesandthen

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

25 Sep 2020, 14:26

rommmcek wrote:
25 Sep 2020, 11:04
tobsto occupied wrote:
23 Sep 2020, 13:26
nope no difference still instant exit of all in a few secs
Last time I made a simulation test and the code worked as intended.
May be your OS doesn't support += operator, so try to replace LoadTime+= 5 with LoadTime= %LoadTime%+5!
yep that works!
User avatar
tobsto occupied
Posts: 148
Joined: 20 Feb 2020, 09:34
GitHub: washingleavesandthen

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

25 Sep 2020, 14:45

rommmcek wrote:
25 Sep 2020, 11:11
tobsto occupied wrote:
24 Sep 2020, 05:37
btw another question how do i make it so my batch exits everything not just if my game exits but if i get an werfault error while the game is still running i wonder
- Fist you assign to the variable "process_name" value "ACM.exe". Then you assign to the same variable value "Werfault.exe". As a result "ACM.exe" is being overwritten by "Werfault.exe". So if you need the value "ACM.exe" later below in the script you don't have it any more!
- The only condition in the script is: If there is %process_name% (in your case "Werfault.exe") in the tasklist then Goto lable :RUNNING. So the script repeats that loop as long "Werfault.exe" process is running.
When "Werfault.exe" process is not running anymore the script will kill "cheatengine-x86_64.exe" , "Texmod.exe" and "Texmod and Game Autolauncher.exe". It will attempt to kill "Werfault.exe" too, but it obviously doesn't exist anymore...

Now on "Werfault.exe" error the process probably doesn't exit by itself (it means the script will loop further on) and that's probably why it doesn't work.
To detect error of the "Werfault.exe" you can monitor e.g. (CPU usage, Memory usage, GPU usage, eventual messages from "Werfault.exe" if any, etc...). Actually how do you know by yourself when "Werfault.exe" has an error?
i guess ive explained wrongfully , what i need is for an additional parameter that monitors for Werfault.exe and should Werfault.exe start to run id then need all the others to autoexit including Werfault.exe

aka a reverse watch function , instead of keeping said apps alive id need all of them to get killed on Werfault.exe bound to said game exe
User avatar
tobsto occupied
Posts: 148
Joined: 20 Feb 2020, 09:34
GitHub: washingleavesandthen

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

25 Sep 2020, 14:49

rommmcek wrote:
25 Sep 2020, 11:12
GPU script: I didn't saw, you've set a good condition (if %z% Lss 20). However the value of the z variable is empty. You have to grab z value with the script we developed which yields something like 41, 52, 0, 4874, 11264, 66. Go on you're so close!
i still dont get it i only need the very last variable ...66 or whatever gpu core usage is then , tbh id set it to 20% core usage instead of 66%

some more help would be appreciated for sure im still lost as fuck man
User avatar
rommmcek
Posts: 1190
Joined: 15 Aug 2014, 15:18

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

26 Sep 2020, 18:57

tobsto occupied wrote:
25 Sep 2020, 14:45
aka a reverse watch function , instead of keeping said apps alive id need all of them to get killed on Werfault.exe bound to said game exe

Code: Select all

:RUNNING
  timeout /t 5
  tasklist|findstr %process_name% > nul && (
  taskkill /F /T /IM "cheatengine-x86_64.exe" & taskkill /F /T /IM "Texmod.exe") & (
  taskkill /F /T /IM "Texmod and Game Autolauncher.exe" & taskkill /F /T /IM "Werfault.exe" & exit /b)
Goto RUNNING
Note: I debugged new line continuation essential for this layout! I.e. your previous script would work as described, because last two lines were the last one of the script. Here your have Goto in the last line so the "killing" commands have to be in one line or must use correct continuation syntax!
User avatar
rommmcek
Posts: 1190
Joined: 15 Aug 2014, 15:18

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

26 Sep 2020, 19:02

tobsto occupied wrote:
25 Sep 2020, 14:49
... i only need the very last variable ...66 or whatever gpu core usage is then ...
Exactly and grabbing all the other values won't harm (we can trim them later away). I just want you to realize that you already have all the bits to assign z variable and solve the puzzle!
User avatar
tobsto occupied
Posts: 148
Joined: 20 Feb 2020, 09:34
GitHub: washingleavesandthen

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

27 Sep 2020, 12:08

rommmcek wrote:
26 Sep 2020, 19:02
tobsto occupied wrote:
25 Sep 2020, 14:49
... i only need the very last variable ...66 or whatever gpu core usage is then ...
Exactly and grabbing all the other values won't harm (we can trim them later away). I just want you to realize that you already have all the bits to assign z variable and solve the puzzle!
like this? >

Code: Select all

@echo OFF
set VK_LAYER_PATH="" "DOOM;%VK_LAYER_PATH%"
set VK_INSTANCE_LAYERS=VK_LAYER_reshade
@start "" "DOOMx64vk.exe" +devMode_Enable 1 +com_restarted 1 +com_gameMode 1 +com_skipIntroVideo 1 +exec DOOMConfig.cfg 1 +image_usecompression 0 +com_skipKeyPressOnLoadScreens 1
TIMEOUT /t 20
:: set process_name:
 set process_name=DOOMx64vk.exe
 ::=================================================================
::Launch the App
tasklist | findstr /i %process_name% > nul && start /min "" "easy access to campaign.ahk"
cd /D "C:\Program Files\NVIDIA Corporation\NVSMI\"
:GPU
for /f skip^=8^ tokens^=1-3^ delims^=^| %%a in ('"nvidia-smi.exe"') do (
    for /f "tokens=1-6 delims= " %%g in ("%%a") do set u=%%g & set v=%%h) & set w=%%j) & (
    for /f "tokens=1-3 delims= " %%g in ("%%b") do set x=%%g & set y=%%i) & (
    for /f "tokens=1-2 delims= " %%g in ("%%c") do set z=%%g) & goto :breakForLoop
:breakForLoop
rem set /a u+=0 & set /a v+=0 & set /a w+=0 & set /a x+=0 & set /a z+=0
rem set /a u=u & set /a v=v & set /a w=w & set /a x=x & set /a z=z
echo %u%, %v%, %w%, %x%, %y%, %z%
rem pause
timeout /t 5
goto GPU
if %z20% Lss 20 TaskKill /F /im %process_name% & goto RUNNING
timeout /t 3
:RUNNING
tasklist|findstr %process_name% > nul &&
    taskkill /F /T /IM "cheatengine-x86_64.exe" & taskkill /F /T /IM "Werfault.exe" & exit /b
timeout /t 1
GOTO RUNNING

dont work.... :problem:

p.s 20 is supposed to be the gpu core usage threshold aka 20% usage so ive set z20 and Lss 20
Last edited by tobsto occupied on 27 Sep 2020, 12:14, edited 2 times in total.
User avatar
tobsto occupied
Posts: 148
Joined: 20 Feb 2020, 09:34
GitHub: washingleavesandthen

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

27 Sep 2020, 12:12

rommmcek wrote:
26 Sep 2020, 18:57
tobsto occupied wrote:
25 Sep 2020, 14:45
aka a reverse watch function , instead of keeping said apps alive id need all of them to get killed on Werfault.exe bound to said game exe

Code: Select all

:RUNNING
  timeout /t 5
  tasklist|findstr %process_name% > nul && (
  taskkill /F /T /IM "cheatengine-x86_64.exe" & taskkill /F /T /IM "Texmod.exe") & (
  taskkill /F /T /IM "Texmod and Game Autolauncher.exe" & taskkill /F /T /IM "Werfault.exe" & exit /b)
Goto RUNNING
Note: I debugged new line continuation essential for this layout! I.e. your previous script would work as described, because last two lines were the last one of the script. Here your have Goto in the last line so the "killing" commands have to be in one line or must use correct continuation syntax!
thanks for that but it still dont solve my issue of me needing the ACM.exe essentially to being killed as well as soon as Werfault.exe thats tied to the game exe pops up
User avatar
rommmcek
Posts: 1190
Joined: 15 Aug 2014, 15:18

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

28 Sep 2020, 10:07

tobsto occupied wrote:
27 Sep 2020, 12:12
thanks for that but it still dont solve my issue of me needing the ACM.exe essentially to being killed as well as soon as Werfault.exe thats tied to the game exe pops up
rommmcek wrote:
25 Sep 2020, 11:11
- Fist you assign to the variable "process_name" value "ACM.exe". Then you assign to the same variable value "Werfault.exe". As a result "ACM.exe" is being overwritten by "Werfault.exe". So if you need the value "ACM.exe" later below in the script you don't have it any more!
But you can always add another TaskKill line to the existing ones (respecting continuation syntax of course).
User avatar
rommmcek
Posts: 1190
Joined: 15 Aug 2014, 15:18

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

28 Sep 2020, 10:34

tobsto occupied wrote:
27 Sep 2020, 12:08
like this? >
Finally you did it! Important is to start! I can see three bugs at first sight:
1. You took the wrong scriptlet, which outputs alphanumeric values. rem means remark i.e. comment such line is not executed. So you have uncomment one of the lines. One of them won't work for you remember:
rommmcek wrote:
25 Sep 2020, 11:04
May be your OS doesn't support += operator
2. If statement is outside the loop of :GPU label and goto GPU command. That means the loop will repeat for ever no matter what was the condition in If statement, doing nothing.
3.
rommmcek wrote:
25 Sep 2020, 11:12
you've set a good condition (if %z% Lss 20)
So why did you change it (to the bad)?
User avatar
rommmcek
Posts: 1190
Joined: 15 Aug 2014, 15:18

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

28 Sep 2020, 10:43

Some tutorial links:
- Batch Script
- Windows CMD commands
- Batch File Programming

-Batch script loop

P.s.: How did I get them? As anything on the web by browsing! Now keep going!

[Edit]: Just found and added a nice thread for Batch loops!
Last edited by rommmcek on 01 Dec 2020, 15:33, edited 1 time in total.
User avatar
tobsto occupied
Posts: 148
Joined: 20 Feb 2020, 09:34
GitHub: washingleavesandthen

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

29 Sep 2020, 08:10

rommmcek wrote:
28 Sep 2020, 10:07
tobsto occupied wrote:
27 Sep 2020, 12:12
thanks for that but it still dont solve my issue of me needing the ACM.exe essentially to being killed as well as soon as Werfault.exe thats tied to the game exe pops up
rommmcek wrote:
25 Sep 2020, 11:11
- Fist you assign to the variable "process_name" value "ACM.exe". Then you assign to the same variable value "Werfault.exe". As a result "ACM.exe" is being overwritten by "Werfault.exe". So if you need the value "ACM.exe" later below in the script you don't have it any more!
But you can always add another TaskKill line to the existing ones (respecting continuation syntax of course).
not what i need , im talking about setting more than one watch process, one process that instant exits all on werfault popup and one that instant exits on acm.exe being exited, guess ill just have to chain 2 separate batch files together then, have one execute the other
User avatar
tobsto occupied
Posts: 148
Joined: 20 Feb 2020, 09:34
GitHub: washingleavesandthen

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

29 Sep 2020, 08:13

rommmcek wrote:
28 Sep 2020, 10:34
tobsto occupied wrote:
27 Sep 2020, 12:08
like this? >
Finally you did it! Important is to start! I can see three bugs at first sight:
1. You took the wrong scriptlet, which outputs alphanumeric values. rem means remark i.e. comment such line is not executed. So you have uncomment one of the lines. One of them won't work for you remember:
rommmcek wrote:
25 Sep 2020, 11:04
May be your OS doesn't support += operator
2. If statement is outside the loop of :GPU label and goto GPU command. That means the loop will repeat for ever no matter what was the condition in If statement, doing nothing.
3.
rommmcek wrote:
25 Sep 2020, 11:12
you've set a good condition (if %z% Lss 20)
So why did you change it (to the bad)?
dude please seriously this is some agonizing shit , please just help a dude out here will ya , i know you got the solution , do me the favor here will ya seriously please i aint gettin nowhere with this mindfuckery :cry: :crazy: :| :wtf: :headwall: :headwall: :headwall:
User avatar
tobsto occupied
Posts: 148
Joined: 20 Feb 2020, 09:34
GitHub: washingleavesandthen

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

29 Sep 2020, 08:21

p.s those links did NOT help the situation -.-'
User avatar
tobsto occupied
Posts: 148
Joined: 20 Feb 2020, 09:34
GitHub: washingleavesandthen

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

29 Sep 2020, 10:26

tobsto occupied wrote:
29 Sep 2020, 08:10
rommmcek wrote:
28 Sep 2020, 10:07
tobsto occupied wrote:
27 Sep 2020, 12:12
thanks for that but it still dont solve my issue of me needing the ACM.exe essentially to being killed as well as soon as Werfault.exe thats tied to the game exe pops up
rommmcek wrote:
25 Sep 2020, 11:11
- Fist you assign to the variable "process_name" value "ACM.exe". Then you assign to the same variable value "Werfault.exe". As a result "ACM.exe" is being overwritten by "Werfault.exe". So if you need the value "ACM.exe" later below in the script you don't have it any more!
But you can always add another TaskKill line to the existing ones (respecting continuation syntax of course).
not what i need , im talking about setting more than one watch process, one process that instant exits all on werfault popup and one that instant exits on acm.exe being exited, guess ill just have to chain 2 separate batch files together then, have one execute the other

yeah ..nope, cant figure this one out , as said all i need is for as soon as Werfault.exe running for my games exe aka ACM.exe to exit and if ACM.exe exits for the rest in Running to be killed
User avatar
rommmcek
Posts: 1190
Joined: 15 Aug 2014, 15:18

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

29 Sep 2020, 15:12

tobsto occupied wrote:
29 Sep 2020, 08:13
not what i need , im talking about setting more than one watch process

Code: Select all

@echo OFF
:: set process_name:
 set process_Acm=ACM.exe & set process_Wer=Werfault.exe
 ::==================================================================
::Launch the App
 start "" "Texmod and Game Autolauncher.exe"
 timeout /t 90
:RUNNING
  timeout /t 5
  tasklist|findstr %process_Wer% > nul && Goto Terminate
  tasklist|findstr %process_Acm% > nul && Goto RUNNING
:Terminate
  taskkill /F /T /IM "cheatengine-x86_64.exe" & taskkill /F /T /IM "Texmod.exe" & taskkill /F /T /IM "ACM.exe"
  taskkill /F /T /IM "Texmod and Game Autolauncher.exe" & taskkill /F /T /IM "Werfault.exe" & exit /b
P.s.: I'm not sure. For that code to work Acm.exe must be running. Once it exits the "TaskKill" commands will be triggered as well as when Werfault.exe appears.
User avatar
rommmcek
Posts: 1190
Joined: 15 Aug 2014, 15:18

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

29 Sep 2020, 15:20

GPU:
Try to fix this batch (it has similar bug as in your code):

Code: Select all

@echo OFF
set /a CountDown=66
:RUNNING
    echo Hi Tobsto, are you free?
    TimeOut /t 3
    set /a CountDown= %CountDown% - 20
    echo No, I'm occupied (currently at %CountDown%%)
    TimeOut /t 3
GOTO RUNNING
    if %CountDown% Lss 30 GoTo FreeTobsto
:FreeTobsto
    echo Ok, I'm free now, I think I get it!
    pause & exit /b
tobsto occupied wrote:
29 Sep 2020, 08:21
p.s those links did NOT help the situation
What did you not understand?
User avatar
tobsto occupied
Posts: 148
Joined: 20 Feb 2020, 09:34
GitHub: washingleavesandthen

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

30 Sep 2020, 04:25

rommmcek wrote:
29 Sep 2020, 15:20
GPU:
Try to fix this batch (it has similar bug as in your code):

Code: Select all

@echo OFF
set /a CountDown=66
:RUNNING
    echo Hi Tobsto, are you free?
    TimeOut /t 3
    set /a CountDown= %CountDown% - 20
    echo No, I'm occupied (currently at %CountDown%%)
    TimeOut /t 3
GOTO RUNNING
    if %CountDown% Lss 30 GoTo FreeTobsto
:FreeTobsto
    echo Ok, I'm free now, I think I get it!
    pause & exit /b
tobsto occupied wrote:
29 Sep 2020, 08:21
p.s those links did NOT help the situation
What did you not understand?
finally !!! a starting point i can start to tinker with , wohoo!!! hype!

p.s those links werent helping me...you ok , but me to me the info contained was just mumbo jumbo tbh :lolno: :crazy:

Return to “Gaming”

Who is online

Users browsing this forum: mikeyww and 10 guests