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
tobsto occupied
Posts: 149
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:27

rommmcek wrote:
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.
nice...shall give it a whirl
User avatar
tobsto occupied
Posts: 149
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:48

update> dont work ...wont exit everything on acm.exe exit and wont on werfault.exe execution aka popup
User avatar
tobsto occupied
Posts: 149
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, 07:23

tobsto occupied wrote:
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:
damn ...once i started to read into the batch the hype died instantly lols...but for real im lost as ever :problem: :think: thought it was a base gpu batch with me just having to change variables ...goddamned it i aint gonna get nowhere with this , been hitting my head against a brick wall over here and it wont budge :headwall:
User avatar
tobsto occupied
Posts: 149
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, 07:34

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
set /a u+=0 & set /a v+=0 & set /a w+=0 & set /a x+=0 & set /a z+=0
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%
pause
timeout /t 5
goto GPU
if %z% Lss 20 TaskKill /F /im %process_name% & goto RUNNING
set /a CountDown=66
timeout /t 3
GOTO RUNNING
    if %CountDown% Lss 30 GoTo GPU
:RUNNING
tasklist|findstr %process_name% > nul &&
    taskkill /F /T /IM "cheatengine-x86_64.exe" & taskkill /F /T /IM "Werfault.exe"
    set /a CountDown= %CountDown% - 20
    timeout /t 1
 & exit /b
dont work for shit .... :think:
User avatar
rommmcek
Posts: 1219
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

02 Oct 2020, 15:58

tobsto occupied wrote:
30 Sep 2020, 04:48
update> dont work ...wont exit everything on acm.exe exit and wont on werfault.exe execution aka popup
These two lines are for exiting.

Code: Select all

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
Which process does not exit?
If it is not present in above lines then it cannot exit, so you have to add the command to do that.
May be there should be added some TimeOut after each TaskKill command...
I cannot test things like these for you!
User avatar
rommmcek
Posts: 1219
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

02 Oct 2020, 16:01

tobsto occupied wrote:
30 Sep 2020, 07:23
damn ...once i started to read into the batch the hype died instantly lols...
rommmcek wrote:
28 Sep 2020, 10:34
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.
So do it and it will work!
rommmcek wrote:
28 Sep 2020, 10:34
So you have to uncomment one of the lines.
why did you uncomment three lines? And note:
rommmcek wrote:
25 Sep 2020, 11:04
May be your OS doesn't support += operator
tobsto occupied wrote:
30 Sep 2020, 04:25
to me the info contained was just mumbo jumbo
Be more precise! Which example was for you just "mumbo jumbo"?
User avatar
tobsto occupied
Posts: 149
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

03 Oct 2020, 02:00

rommmcek wrote:
02 Oct 2020, 15:58
tobsto occupied wrote:
30 Sep 2020, 04:48
update> dont work ...wont exit everything on acm.exe exit and wont on werfault.exe execution aka popup
These two lines are for exiting.

Code: Select all

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
Which process does not exit?
If it is not present in above lines then it cannot exit, so you have to add the command to do that.
May be there should be added some TimeOut after each TaskKill command...
I cannot test things like these for you!
all of em wont exit ..none ..niente ..nadda

lemme reiterate ...those mentioned lines are indeed bound to running

what i need is for everything in running to be killed IF : ACM.exe exits OR Werfault.exe window pops up


and the last script you posted dont do that matter of fact it wont kill anything , somethings bugged ... :|

p.s this has nothing to do with not being able to test it for me since you dont have said app :problem:
User avatar
tobsto occupied
Posts: 149
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

03 Oct 2020, 02:08

rommmcek wrote:
02 Oct 2020, 16:01
tobsto occupied wrote:
30 Sep 2020, 07:23
damn ...once i started to read into the batch the hype died instantly lols...
rommmcek wrote:
28 Sep 2020, 10:34
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.
So do it and it will work!
rommmcek wrote:
28 Sep 2020, 10:34
So you have to uncomment one of the lines.
why did you uncomment three lines? And note:
rommmcek wrote:
25 Sep 2020, 11:04
May be your OS doesn't support += operator
tobsto occupied wrote:
30 Sep 2020, 04:25
to me the info contained was just mumbo jumbo
Be more precise! Which example was for you just "mumbo jumbo"?
all of it lols , but now honestly PLEASE !!!!!!!! help me out on this one shits not a joke no more , im serious h e l p me o u t here , im NOT as experienced nor do i code for shit you shouldve noticed this for months now lols , but serioulsy man help me the fuck out and i mean with a full batch , ive already posted one but that ones obviously containing garbage and dont do shit considering the gpu core threshold feature , fuck ill wait if i have to cause i REALLY need this function :lolno: :crazy: :thumbdown: :headwall: :headwall: :headwall: :headwall: :headwall:
User avatar
tobsto occupied
Posts: 149
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

13 Oct 2020, 14:22

yep still need help on this my dude shall be waiting no rush but just letting you know im counting on ya , since i need your smarts to get this going , im just way to fucking stupid to figure this out aka a working script , thanks :think:
User avatar
tobsto occupied
Posts: 149
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 Oct 2020, 03:19

any news? really need this bad my dude , thanks
User avatar
tobsto occupied
Posts: 149
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 Nov 2020, 12:23

anybody able to help out here , please somebody
User avatar
tobsto occupied
Posts: 149
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

13 Dec 2020, 03:11

common its almost christmas time and nobody wanna help out? please
User avatar
tobsto occupied
Posts: 149
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

28 Dec 2020, 12:19

ok so after a long and tedious fiddling and searching this is what ive came up with for the gpu threshold function ...still dont work tho, damn it

Code: Select all

@echo off

set "_ngpu=nvidia-smi.exe"
set "_prc_name=DevilMayCry5.exe"
set "_2kill=Steam,DMCVTrainer,cheatengine-x86_64,Werfault"
::============================================================
::Launch the App
start "" "steam://rungameid/601150"
TIMEOUT /t 30
tasklist | findstr /i "DevilMayCry5.exe" > nul && start /min "" "DMCVTrainer.exe"

%:^0
timeout/t 30 | echo/Starting Steam ... 
tasklist/svc /fo list|find/i "%_prc_name%" >nul || goto %:^0

%:^V
echo/ & call start "" /min "DMCVTrainer.exe" 
pushd "C:\Program Files\NVIDIA Corporation\NVSMI" 
for /f eol^=^(usebackq^tokens^=10delims^=^|^  %%i in (`
%ComsPec% /v /c "nvidia-smi.exe|find "%%""`)do 2>nul (
    .\nvidia-smi.exe ^| find "%%%")do if %%~i lss 20 (
	2>nul taskkill/f /im "%_prc_name%">nul && goto %:^)
    )else echo\Loop... %%:^^V |timeout/t 3 && goto %:^V

%:^)
popd && for %%i in (%_2kill%)do 2>nul taskkill/f /t /im "%%~i.exe" >nul & (
if /i "%%~i.exe"=="Werfault.exe"  (echo\Lopp kill... |timeout /t 3 & goto %:^V )


also wont kill bottom processes either if game isnt running no more, yeah shits sooo easy to figure out ey :(
:? :headwall:
User avatar
rommmcek
Posts: 1219
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

01 Jan 2021, 13:31

Now you came with a whole new code! Why? You didn't provide source!, or is this completely your work?
Why do you try to solve all steps at once. I would go step by step!
We already had a working code for retrieving Gpu usage. It was bulky, because I asked you couple of times wich value is relevant and you answered only once it was written!, but it's easy to shirk it.
Nevertheless alternatives are always good, it inspired me with some new ideas.
Just at the first look of the For /f loop: line break after backquote is a bug! Should be only after opening bracket or after escape character ^. Further below I don't follow any more (I don't know much batch coding), but it seems to me it is unnecessarily complicated (once you have Gpu usage value, you already know what to do - it's the same as for Cpu usage value threshold).
bye!
User avatar
tobsto occupied
Posts: 149
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

02 Jan 2021, 11:02

well tbh ive got someone from superuser thats trying to help out lols, but we both me and him are struggling to get a working script as you may see , his redone script actually made stuff worse? lols

as i said i need value Z which is Gpu usage


not sure if youve noticed but im desperate in getting a proper working script here lols...seriously tho
Last edited by tobsto occupied on 02 Jan 2021, 11:08, edited 1 time in total.
User avatar
tobsto occupied
Posts: 149
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

02 Jan 2021, 11:06

btw ive setup ...another thread for this over at it ninja as well


https://www.itninja.com/question/how-to-kill-a-app-once-gpu-usage-is-below-set-threshold-using-a-given-gpu-per-nvidia-smi-in-windows

im gathering all my internet powaz to finally solve this issue ... for someone to solve this issue lols, people dont believe me when i tell them im not a scripter ...well i hope ive proven myself by now
User avatar
rommmcek
Posts: 1219
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

02 Jan 2021, 12:07

I don't see superuser link!
Oh, you do code, that's for sure, but if you'll stick with posts without code, seriously, I'm out!!
User avatar
tobsto occupied
Posts: 149
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

02 Jan 2021, 12:58

and heres the gpu threshold code that dont work >

Code: Select all

@echo OFF

@start "" "folding.exe"

TIMEOUT /t 20

:: set process_name:

 set process_name=folding.exe

 ::=================================================================

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

set /a u+=0 & set /a v+=0 & set /a w+=0 & set /a x+=0 & set /a z+=0

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%

pause

timeout /t 5

goto GPU

if %z% Lss 20 TaskKill /F /im %process_name% & goto RUNNING

timeout /t 3

:RUNNING

tasklist|findstr %process_name% > nul &&

    taskkill /F /T /IM "Werfault.exe" & exit /b

timeout /t 1

GOTO RUNNING


which in turn essentially has to be made to work with this script replacing the mem and cpu threshold function with the gpu threshold one>

Code: Select all

@echo OFF
::========= Set cpuThreshold [%] and memThreshold [according to displayed value in Cmd window] =========
set /a cpuThreshold=10        & set /a memThreshold=450000
::initialize vars                            and set process_name:
set /a low=0 & setlocal enableDelayedExpansion & set process_name=DevilMayCry5
set pn=%process_name:.exe=%
::==================================================================
::Launch the App
start "" "steam://rungameid/601150"
TIMEOUT /t 30
tasklist | findstr /i %process_name% > nul && start /min "" "DMCVTrainer.exe"
tasklist | findstr /i %process_name% > nul && start /min "" "SSSiyanCollabTU5.CT"
::Get NumberOfCores
for /f "tokens=*" %%f in ('wmic cpu get NumberOfCores /value ^| find "="') do set %%f
:CheckCpuAndMem
set /a process_snapshot=0 & set /a memUsg=0
::CPU
for /f skip^=2^ tokens^=3^ delims^=^" %%p in (
    'typeperf "\Process(%pn%)%% Processor Time" -sc 1') do for /f "tokens=1 delims=." %%a in (
    "%%p") do set /a process_snapshot=%%a/%NumberOfCores%
if %process_snapshot% LSS %cpuThreshold% (set /a low+=1) else (set /a low=0)
::Mem
for /f "tokens=5" %%p in (
  'tasklist ^|findstr %process_name%') do for /f "tokens=1,2,3 delims=." %%a in ("%%p") do set /a memUsg=%%a%%b%%c/1000
if %memUsg% lss %memThreshold% (set /a low+=1) else (set /a low=0)
::echo feedback
@echo process_snapshot: %process_snapshot%, memUsage: %memUsg%;    LowCpuAndMem: %low%
::12 checks (Cpu & Mem) times 3 sec timeout plus processing delay yields ca 30 sec
if %low% GEQ 12 taskkill /F /T /IM %process_name% & goto RUNNING
timeout /t 3
tasklist|findstr %process_name% > nul && GOTO CheckCpuAndMem
:RUNNING
tasklist|findstr %process_name% > nul && (
    taskkill /F /T /IM cheatengine-x86_64.exe) & taskkill /F /T /IM DMCVTrainer.exe & (
    taskkill /F /T /IM Steam.exe) & taskkill /F /T /IM Werfault.exe & exit /b
timeout /t 1
GOTO RUNNING
p.s no need to be so pissy about it , i need your assistance and aint gettin nowhere here, and not sure if youve noticed but YOU are pretty much the only one on the net thats able to make this work , as the links ive linked to should prove so PLEASE help me

Return to “Gaming”

Who is online

Users browsing this forum: Donuts23, Qhimin and 18 guests