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: 140
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

07 Sep 2020, 15:55

rommmcek wrote:
06 Sep 2020, 10:52
tobsto occupied wrote:
30 Aug 2020, 12:51
uhhhh no, its supposed to kill Texmod and Werfault ...which happens sometimes, once game exits not the game on startup
Oh, sorry again, superficial reading! Hope "game exits" is right (not "game crashes"). Try:

Code: Select all

. . .
TIMEOUT /t 30
:RUNNING
 timeout /t 5
 tasklist|findstr DMC-DevilMayCry.exe > nul && Goto RUNNING
 taskkill /F /T /IM Texmod.exe & taskkill /F /T /IM Werfault.exe & exit /b
P.s.: Have increased timeout to check every 5 sec. O.k.? Then be sure TIMEOUT /t 30
is long enough to load the game, otherwise script will trigger the TaskKill routine and exit!
yeps works a charm ...thanks my dude, now onto the gpu issue
User avatar
tobsto occupied
Posts: 140
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

07 Sep 2020, 15:56

rommmcek wrote:
06 Sep 2020, 11:05
For GPU first just run the code:

Code: Select all

@echo OFF
cd /D "C:\Program Files\NVIDIA Corporation\NVSMI\"
:GPU
for /f skip^=6^ 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
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 the periodical output isn't something like: 41, 52, 181, 4874, 11264, 66, then repeat it with skip^=7^ and so on. Then you can set the condition.
P.s.: I still don't know for sure wich variable is relevant (Probably 4874 for your previous snapshot output)!
the 66 is the gpu core usage that being the relevant variable, anyhow gimme a sec..
User avatar
tobsto occupied
Posts: 140
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

07 Sep 2020, 16:14

ok so currently skip^=6^ only gives me 6 0s as output , skip^=7^ ...same, but with skip^=8^ i get a proper readout , except the 3rd readout is a 0 the sixth which is the gpu core and all others as well work and show like so :

41, 52, 0, 4874, 11264, 66
User avatar
rommmcek
Posts: 1123
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

09 Sep 2020, 14:18

tobsto occupied wrote:
07 Sep 2020, 15:55
yeps works a charm ...
Try this one (no guessing of load time):

Code: Select all

 @echo OFF
:: set process_name:
 set process_name=DMC-DevilMayCry.exe
 ::==================================================================
::Launch the App
 start "" "Texmod and Game Autolauncher.exe"
 
:Loading
 timeout /t 5
 tasklist|findstr %process_name%> nul && Goto Running
 Goto Loading

:RUNNING
 timeout /t 5
 tasklist|findstr %process_name > nul && Goto RUNNING
 taskkill /F /T /IM Texmod.exe & taskkill /F /T /IM Werfault.exe & exit /b
User avatar
rommmcek
Posts: 1123
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

09 Sep 2020, 14:35

tobsto occupied wrote:
07 Sep 2020, 16:14
except the 3rd readout is a 0
Was the output really exactly 41, 52, 0, 4874, 11264, 66? Try to comment 10'th line to look like rem set /a u=u & set /a v=v & set /a w=w & set /a x=x & set /a z=z and let me know what is the output, so we can see which number the script grabs (although we actually don't need it, because relevant variable is the last one)!
tobsto occupied wrote:
07 Sep 2020, 16:17
ok...so now what?
If the relevant value is "66" then it corresponds with z variable. So you have to set the condition:

Code: Select all

if %z% Lss 40 TaskKill /F /im "My Game.exe"
Give it a try, if does not work as desired post the code so we can fix it (hopefully)!

bye!
User avatar
tobsto occupied
Posts: 140
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

09 Sep 2020, 19:33

rommmcek wrote:
09 Sep 2020, 14:18
tobsto occupied wrote:
07 Sep 2020, 15:55
yeps works a charm ...
Try this one (no guessing of load time):

Code: Select all

 @echo OFF
:: set process_name:
 set process_name=DMC-DevilMayCry.exe
 ::==================================================================
::Launch the App
 start "" "Texmod and Game Autolauncher.exe"
 
:Loading
 timeout /t 5
 tasklist|findstr %process_name%> nul && Goto Running
 Goto Loading

:RUNNING
 timeout /t 5
 tasklist|findstr %process_name > nul && Goto RUNNING
 taskkill /F /T /IM Texmod.exe & taskkill /F /T /IM Werfault.exe & exit /b

ohhhh ...nice , even better! shall try asap
User avatar
tobsto occupied
Posts: 140
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

09 Sep 2020, 19:41

yeah nope that dont work instant exits the game pretty much , looks like the good ol timer method will be required, ok so the old timer method works BUT it wont exit the Autoit script exe aka Texmod and Game Autolauncher.exe, ive tested this by stealing the focus from the autoit script exe and thus it stops then texmod gets exited but not the autoit exe , this is the current batchfile :

@echo OFF
::initialize vars and set process_name:
set /a low=0 & setlocal enableDelayedExpansion & set process_name=DMC-DevilMayCry.exe
set pn=%process_name:.exe=%
::==================================================================
::Launch the App
start "" "Texmod and Game Autolauncher.exe"
TIMEOUT /t 30
:RUNNING
timeout /t 5
tasklist|findstr DMC-DevilMayCry.exe > nul && (
taskkill /F /T /IM cheatengine-x86_64.exe) & taskkill /F /T /IM Texmod.exe & (
taskkill /F /T /IM Texmod and Game Autolauncher.exe) & exit /b
timeout /t 1
GOTO RUNNING
User avatar
tobsto occupied
Posts: 140
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

09 Sep 2020, 20:09

rommmcek wrote:
09 Sep 2020, 14:35
tobsto occupied wrote:
07 Sep 2020, 16:14
except the 3rd readout is a 0
Was the output really exactly 41, 52, 0, 4874, 11264, 66? Try to comment 10'th line to look like rem set /a u=u & set /a v=v & set /a w=w & set /a x=x & set /a z=z and let me know what is the output, so we can see which number the script grabs (although we actually don't need it, because relevant variable is the last one)!
User avatar
tobsto occupied
Posts: 140
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

09 Sep 2020, 20:10

well am now getting the following output after replacing line 10>

38%, 45C, %j), 2028MiB, 11264MiB, 23%
User avatar
tobsto occupied
Posts: 140
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

09 Sep 2020, 20:12

if %z% Lss 40 TaskKill /F /im "My Game.exe"


where does this go? use my doom batchfile as example, thanks
User avatar
rommmcek
Posts: 1123
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

09 Sep 2020, 20:14

Sorry there were at least two typos (one of them critical)! Try:

Code: Select all

 @echo OFF
:: set process_name:
 set process_name=DMC-DevilMayCry.exe
 ::==================================================================
::Launch the App
 start "" "Texmod and Game Autolauncher.exe"
 
:Loading
 timeout /t 5
 tasklist|findstr %process_name% > nul && Goto Running
 Goto Loading

:RUNNING
 timeout /t 5
 tasklist|findstr %process_name% > nul && Goto RUNNING
 taskkill /F /T /IM Texmod.exe & taskkill /F /T /IM Werfault.exe & exit /b
Other things some other time!
User avatar
tobsto occupied
Posts: 140
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

09 Sep 2020, 22:31

yep worked, but ill use the timer function since i would like for all the apps mentioned to autoclose should the game not be running after a certain amount of time , it works with my mentioned frankenhack that ive conjured up said hack as well autocloses the autoit script exe
, which autocloses any apps launched should mentioned app not be launched in 30 seconds, but i recon i can use this for certain usecases , thanks and no rush ill be lurking in the shadows for the gpu solution , thanks as usual my dude and stay healthy and take care ...till next time
User avatar
tobsto occupied
Posts: 140
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

09 Sep 2020, 23:06

ok so i figured out why certain apps like ahk or autoit scripts wouldnt exit you need to add " at the start of the exe and at the end of the .exe as such :

Code: Select all

 @echo OFF
:: set process_name:
 set process_name=DMC-DevilMayCry.exe
 ::==================================================================
::Launch the App
start "" "Texmod and Game Autolauncher.exe"
timeout /t 30
:RUNNING
timeout /t 5
 tasklist|findstr %process_name% > nul && Goto RUNNING
 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
--------------------------------------------------------------

so essentially apps should then by default always be encased with " "
for maximum compatibility for all , works, now all apps besides the game will autoexit if the game isnt running in 30 sec. or will autoexit on game exit ...same thing

of course you can add additional lines that wont even launch certain apps at all without the game running , but in this instance we only got texmod and the autoit autolauncher script exe which we need for the game , would you for example want only a app for example a trainer , Cheat Table etc . be run while the game is running youd add this under Launch App, example:

Code: Select all

tasklist | findstr /i %process_name% > nul && start "" "DMCVTrainer.exe"
tasklist | findstr /i %process_name% > nul && start "" "SSSiyanCollabTU5.CT"

p.s : ive noticed with certain games that for example with doom 2016 when i launch it the very first time per batch which launches an AHK Script .. the AHK Script wont run BUT once i exit the game and relaunch it then the script works without issues , this is the ahk script:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;CoordMode, Mouse, Client ; not needed
WinWait, % Title:= "DOOMx64vk ahk_exe DOOMx64vk.exe",, 30
WinActivate, % Title
WinWaitActive, % Title,, 30
;Sleep, 3000 ; you said 30 sec. ???
Sleep, 30000 ; 30 sec. ; unclear!!!
ControlSend,, {Enter}, % Title ; alternative that works even if cmd is not 
sleep, 300
ControlSend,, {Enter}, % Title ; alternative that works even if cmd is not 
sleep 300
ControlSend,, {Enter}, % Title ; alternative that works even if cmd is not 
ExitApp
----------------------------------------------------------

a solution to this odd behaviour for ahk scripts with some games maybe some kind of force flag or something or reloop? thanks in advance
Last edited by gregster on 10 Sep 2020, 00:57, edited 1 time in total.
Reason: Added code tags to another wall of text... again. :-]
User avatar
tobsto occupied
Posts: 140
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

10 Sep 2020, 18:44

@Mod and yet again i thanks , my bad man gotta get used to abit of formatting i recon lols
User avatar
rommmcek
Posts: 1123
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

15 Sep 2020, 13:11

To exit after 1 minute (60 sec) if game isn't loaded at all try:

Code: Select all

 @echo OFF
:: set process_name:
 set process_name=DMC-DevilMayCry.exe
 ::==================================================================
::Launch the App
 start "" "Texmod and Game Autolauncher.exe"
 
:Loading
 timeout /t 5 & set /a LoadTime+= 5
 if LoadTime Geq 60 Goto Running
 tasklist|findstr %process_name% > nul && Goto Running
 Goto Loading

:RUNNING
 timeout /t 5
 tasklist|findstr %process_name% > nul && Goto RUNNING
 taskkill /F /T /IM Texmod.exe & taskkill /F /T /IM Werfault.exe & exit /b
User avatar
rommmcek
Posts: 1123
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

15 Sep 2020, 13:21

GPU:
1. Grab relevant variable value
2. Use the condition to exit the game or
3. Repeat this after small timeout

Write the code and post it!

P.s.: 38%, 45C, %j), 2028MiB, 11264MiB, 23% is pretty strange. To say more about it you should repeat the test and post the fresh GPU info snippet too (taken soon after first test).
User avatar
rommmcek
Posts: 1123
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

15 Sep 2020, 13:27

tobsto occupied wrote:
09 Sep 2020, 23:06
p.s : ive noticed with certain games that for example with doom 2016 when i launch it the very first time per batch which launches an AHK Script .. the AHK Script wont run BUT once i exit the game and relaunch it then the script works without issues , this is the ahk script:
The script waits up to 30 sec for DOOMx64vk ahk_exe DOOMx64vk.exe to exist, then once again 30 sec to become active. May be is this what's bothering you...
User avatar
tobsto occupied
Posts: 140
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

17 Sep 2020, 13:53

rommmcek wrote:
15 Sep 2020, 13:11
To exit after 1 minute (60 sec) if game isn't loaded at all try:

Code: Select all

 @echo OFF
:: set process_name:
 set process_name=DMC-DevilMayCry.exe
 ::==================================================================
::Launch the App
 start "" "Texmod and Game Autolauncher.exe"
 
:Loading
 timeout /t 5 & set /a LoadTime+= 5
 if LoadTime Geq 60 Goto Running
 tasklist|findstr %process_name% > nul && Goto Running
 Goto Loading

:RUNNING
 timeout /t 5
 tasklist|findstr %process_name% > nul && Goto RUNNING
 taskkill /F /T /IM Texmod.exe & taskkill /F /T /IM Werfault.exe & exit /b
nope ...instant exit after a few seconds of loading up ...game hasnt even started lols
User avatar
tobsto occupied
Posts: 140
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

17 Sep 2020, 13:54

rommmcek wrote:
15 Sep 2020, 13:27
tobsto occupied wrote:
09 Sep 2020, 23:06
p.s : ive noticed with certain games that for example with doom 2016 when i launch it the very first time per batch which launches an AHK Script .. the AHK Script wont run BUT once i exit the game and relaunch it then the script works without issues , this is the ahk script:
The script waits up to 30 sec for DOOMx64vk ahk_exe DOOMx64vk.exe to exist, then once again 30 sec to become active. May be is this what's bothering you...
no what my issue is no matter how long i wait the ahk wont do what its supposed to do , only AFTER i exit the game and relaunch it again does the ahk script work proper thats my issue here

Return to “Gaming”

Who is online

Users browsing this forum: Andy-E, Bing [Bot], Killedog and 13 guests