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

17 Sep 2020, 13:57

rommmcek wrote:
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).
uhhh...nothing has changed all i did was what ive posted as explained ...no changes about GPU info in general just lower usage since ive did it while running a different game of course so lower vram and core usage of course, btw write code...you kidding me right you know i dont do code for shit lols :sick: :crazy: :headwall:

as said as example you can use previous posted batch from doom
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

18 Sep 2020, 12:16

tobsto occupied wrote:
17 Sep 2020, 13:53
nope ...instant exit after a few seconds of loading up ...game hasnt even started lols
I can't spot the bug! Try to increase "idle" load time to two minutes: if LoadTime Geq 120 Goto Running
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

18 Sep 2020, 13:26

tobsto occupied wrote:
17 Sep 2020, 13:57
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
I don't think I follow you, anyway try this concept you reported as working:

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.

WinWait, % Title:= "DOOMx64vk ahk_exe DOOMx64vk.exe",, 30
WinActivate, % Title
WinWaitActive, % Title,, 30
Sleep, 5000 ; increase if needed! (original is 30000 ms -> 30 sec.)
#Persistent
SetTimer, InputData, 300
Return

InputData:
    WinActivate, % Title
    KeyWait, Alt
    KeyWait, Ctrl
    KeyWait, LButton
    BlockInput, On
    If WinActive(Title) {
        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
    }
    BlockInput, Off
Return
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

18 Sep 2020, 13:50

tobsto occupied wrote:
17 Sep 2020, 13:57
uhhh...nothing has changed all i did was what ive posted as explained ...no changes about GPU info in general just lower usage since ive did it while running a different game of course so lower vram and core usage of course, btw write code
Without new (fresh) data & pic I can't say anything!
tobsto occupied wrote:
17 Sep 2020, 13:57
you kidding me right you know i dont do code
Yes you do:
Spoiler
rommmcek wrote:
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
@1: The hardest. Copy the code I posted for you!
@2: I posted you the condition too!
@3: Do loop using GoTo and :Label

Post the code and don't warry if it's not working. Describe the fault behavior and we can try to debug it together!

P.s.: Nobody is going to support you for life especially if you aren't prepare to learn anything!
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

19 Sep 2020, 08:02

no life support ...god damn it! i want my money back lols

anyhow as said i REALLY dont know how to continue with this , common man help a bro out here were so close to success i can taste it :lolno: :think:

btw heres the code that dont work >

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"
if %z% 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
besides theres no set amount of time of certain low gpu usage where its supposed to exit
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

19 Sep 2020, 08:54

tobsto occupied wrote:
19 Sep 2020, 08:02
we're so close to success i can taste it
Exactly that's why I want you to participate!

Btw, you made a good start!
Replace tasklist | findstr /i %process_name% > nul && start /min "" "easy access to campaign.ahk" with Step 1 to get GPU value
and replace if %z% Lss 20 TaskKill /F /im %process_name% & goto RUNNING with Step 2 to set the new condition!
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

21 Sep 2020, 02:14

uhhhh ... still dont get it , im lost as fuck
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

21 Sep 2020, 02:30

rommmcek wrote:
18 Sep 2020, 12:16
tobsto occupied wrote:
17 Sep 2020, 13:53
nope ...instant exit after a few seconds of loading up ...game hasnt even started lols
I can't spot the bug! Try to increase "idle" load time to two minutes: if LoadTime Geq 120 Goto Running
nope...still instant exit

works with this one without issues as said:

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
but this one dont work ..instant exit of all on a few secs of loading Texmod:

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 120 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
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

21 Sep 2020, 02:32

rommmcek wrote:
18 Sep 2020, 13:26
tobsto occupied wrote:
17 Sep 2020, 13:57
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
I don't think I follow you, anyway try this concept you reported as working:

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.

WinWait, % Title:= "DOOMx64vk ahk_exe DOOMx64vk.exe",, 30
WinActivate, % Title
WinWaitActive, % Title,, 30
Sleep, 5000 ; increase if needed! (original is 30000 ms -> 30 sec.)
#Persistent
SetTimer, InputData, 300
Return

InputData:
    WinActivate, % Title
    KeyWait, Alt
    KeyWait, Ctrl
    KeyWait, LButton
    BlockInput, On
    If WinActive(Title) {
        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
    }
    BlockInput, Off
Return
that one dont work

this one works>

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
BUT as said only once i relaunch the game fresh
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

22 Sep 2020, 16:59

rommmcek wrote:
18 Sep 2020, 12:16
I can't spot the bug!
But there was one! 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

22 Sep 2020, 17:03

tobsto occupied wrote:
21 Sep 2020, 02:32
this one works
...
BUT as said only once i relaunch the game fresh
Try:

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.

WinWait, % Title:= "DOOMx64vk ahk_exe DOOMx64vk.exe",, 180 ; if there's no load after 3min, exit
if ErrorLevel
    ExitApp

While !WinActive(Title) {
    Sleep, 300
    WinActivate, % Title
}

loop, 3 {
    sleep, 300
    ControlSend,, {Enter}, % Title
}
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

22 Sep 2020, 17:07

GPU: Go back on this thread where we started grabbing Gpu data, read every post once again, find the script that works again (1. step) and short after that I made you a hint how to set the condition (2. step)

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

23 Sep 2020, 13:26

rommmcek wrote:
22 Sep 2020, 16:59
rommmcek wrote:
18 Sep 2020, 12:16
I can't spot the bug!
But there was one! 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 no difference still instant exit of all in a few secs
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

23 Sep 2020, 13:38

rommmcek wrote:
22 Sep 2020, 17:03
tobsto occupied wrote:
21 Sep 2020, 02:32
this one works
...
BUT as said only once i relaunch the game fresh
Try:

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.

WinWait, % Title:= "DOOMx64vk ahk_exe DOOMx64vk.exe",, 180 ; if there's no load after 3min, exit
if ErrorLevel
    ExitApp

While !WinActive(Title) {
    Sleep, 300
    WinActivate, % Title
}

loop, 3 {
    sleep, 300
    ControlSend,, {Enter}, % Title
}
nope , but im gonna try something else simply have the ahk script relaunch from fresh once it exits after a minute ....should fix it , if not ill have the batch launch the game and then exit and relaunch , thatll definitely take care of it , will update you on this one once figured out
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

23 Sep 2020, 13:41

rommmcek wrote:
22 Sep 2020, 17:07
GPU: Go back on this thread where we started grabbing Gpu data, read every post once again, find the script that works again (1. step) and short after that I made you a hint how to set the condition (2. step)

bye!
once again heres the code and it dont work :eh:

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"
if %z% 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
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

23 Sep 2020, 17:19

tobsto occupied wrote:
rommmcek wrote:
22 Sep 2020, 17:03
tobsto occupied wrote:
21 Sep 2020, 02:32
this one works
...
BUT as said only once i relaunch the game fresh
Try:

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.

WinWait, % Title:= "DOOMx64vk ahk_exe DOOMx64vk.exe",, 180 ; if there's no load after 3min, exit
if ErrorLevel
    ExitApp

While !WinActive(Title) {
    Sleep, 300
    WinActivate, % Title
}

loop, 3 {
    sleep, 300
    ControlSend,, {Enter}, % Title
}
nope , but im gonna try something else simply have the ahk script relaunch from fresh once it exits after a minute ....should fix it , if not ill have the batch launch the game and then exit and relaunch , thatll definitely take care of it , will update you on this one once figured out
update> ok so ive figured it out setting the batchfile to launch the ahk once then let it do its thing which just stutters the menu and dont do shit and it autoexiting itself then set a timer to then relaunch the ahk again ...then itll properly execute its commands in the game, guess Doom 2016 is just special like that lols, must be some protection of sorts of its Engine , here is what it looks like>

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"
timeout /t 30
tasklist | findstr /i %process_name% > nul && start /min "" "easy access to campaign.ahk"
if %z% 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
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

23 Sep 2020, 17:23

still got the gpu issue i need help with tho -.-'
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

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

this dont work:

Code: Select all

 @echo OFF
:: set process_name:
 set process_name=ACM.exe
 set process_name=Werfault.exe
 ::==================================================================
::Launch the App
start "" "Texmod and Game Autolauncher.exe"
timeout /t 90
: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
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

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!
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

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.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 14 guests