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

15 Jun 2020, 12:43

I think the script does exactly what you described it should do, but: It cannot prevent malfunction if the focus is changed just after password is being entered and not finished yet. But this is still more true if you enter password manually! To speed up entering the password you can paste it (using Clipboard):

Code: Select all

Clipboard:= "steam password" ; at the start of the script
;…
Send, ^v ; in place of Send, steam password
;...
[Edit]: Check the last script on previous page (it's been edited again to temporarily stop even while Cmd exists).
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

15 Jun 2020, 13:52

im not talking speedier entering , im talking full controled monitoring , so the script pauses immediately at whatever it is doing and only continues exactly where it paused at on refocus , and if focus is lost a million times and regained, yeah i knew this wouldnt be easy but there gotta be a solution :(

p.s thanks for the edit , but still... :(
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

15 Jun 2020, 14:11

Send command sends only in the Active window, never into background window! If you don't want the Send is executed don't activate Login window. It's simple like that.
[Edit]: Try this label subroutine in place of previous

Code: Select all

CheckWindow:
    While !WinActive(Title)
        Sleep, 100
    sleep, 100
    if !WinActive(Title)
        goto CheckWindow
Return
But believe me it makes no sense!
[Edit2]: Better (programmatically more correct) routin:

Code: Select all

CheckWindow:
    While !WinActive(Title) {
        While !WinActive(Title)
            Sleep, 50
        sleep, 300 ; adjust to your liking
    }
Return
Will continue if Window Title is active for at least 300 ms (adjustable).
Last edited by rommmcek on 15 Jun 2020, 14:46, 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

15 Jun 2020, 14:36

yep last subroutine change works , now it stops and continues from where it left off, actually having steam being logged-in in the background with previous routine is what one would need to make sure it gets logged in even on focus loss and what im actually using for said steam login ahk script , but your new one might take care of the next issue i was aiming for actually , the batch conversion to full ahk script, now if your still up for it id be up to having this batch added to the steam ahk script, this is the batch, dont expect me to be able to convert shit tho , but you already knew that , lols :sick: >

Code: Select all

@echo OFF
start "" "Autolaunch DMC5 Steam, required for Playing.ahk"
TIMEOUT /t 20
start "" "steam://rungameid/601150"
TIMEOUT /t 30
tasklist | findstr /i "DevilMayCry5.exe" > nul && start /min "" "DMCVTrainer.exe"
tasklist | findstr /i "DevilMayCry5.exe" > nul && start /min "" "SSSiyanCollabTU5.CT"

for /f "tokens=*" %%f in ('wmic cpu get NumberOfCores /value ^| find "="') do set %%f
GetNumberOfCores.cmd

:Restart
:: starting and assigning your process(es)
set "process_name=DevilMayCry5.exe"

timeout /t 1

::remove .exe suffix if there is
set pn=%process_name:.exe=%

setlocal enableDelayedExpansion

:: this is threshold for 10% (percent)
set /a threshold=3

:CheckCpuLoad
set /a counter=0
:: getting three snapshots of CPU usage of the given process
for /f skip^=2^ tokens^=3^ delims^=^" %%p in ('typeperf "\Process(%pn%)\%% Processor Time"  -sc 3') do (
    set /a counter=counter+1
rem     for /f "tokens=1,2 delims=." %%a in ("%%p") do set "process_snapshot_!counter!=%%a%%b"
    for /f "tokens=1,2" %%a in ("%%p") do set "process_snapshot_!counter!=%%a"
)

:: convert to percentage
set /a process_snapshot_1/= %NumberOfCores%
set /a process_snapshot_2/= %NumberOfCores%
set /a process_snapshot_3/= %NumberOfCores%

:: comment three lines below when threshold is set correctly
@echo %process_snapshot_1%
@echo %process_snapshot_2%
@echo %process_snapshot_3%

TIMEOUT /t 1

rem I modified below condition check since I don't fathom the original one!
:: if all three snapshots are less than 0000010 (now threshold) process will be killed
if %process_snapshot_1% LSS %threshold% if %process_snapshot_2% LSS %threshold% if %process_snapshot_3% LSS %threshold% (
     tskill %pn%
     taskkill /F /T /IM %process_name%
) & goto RUNNING

timeout /t 1
GOTO CheckCpuLoad

:RUNNING
tasklist|findstr DevilMayCry5.exe > nul
if errorlevel 1 (
    timeout /t 1
    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
    taskkill /F /T /IM Autolaunch DMC5 Steam, required for Playing.ahk
) & GOTO ENDLOOP
timeout /t 1
GOTO RUNNING

:ENDLOOP
:: reduce to 1 for the final script!
timeout /t 1

:: optionally to restart again (remove 'rem' below)
rem goto Restart

exit /B
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

15 Jun 2020, 15:09

ok back to the steam ahk part , a slight oversight and i was too hasty , this is how it currently looks>

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.

run, Devil May Cry 5_batch_mode_.bat, D:\Games\Steam
WinWaitActive, % Title:= "C:\Windows\system32\cmd ahk_exe cmd.exe",, 30

Sleep, 5000
ControlSend,, y, % Title ; alternative that works even if cmd is not active
sleep, 300
ControlSend,, {Enter}, % Title ; alternative that works even if cmd is not active
Sleep, 5000
WinWait, % Title:= "Steam Login ahk_exe steam.exe"
        Gosub CheckWindow
Send, my steam password
sleep, 300
        Gosub CheckWindow
ControlSend,, {Enter}, % Title ; alternative that works even if cmd is not active
ExitApp

CheckWindow:
    While !WinActive(Title) {
        While !WinActive(Title)
            Sleep, 50
        sleep, 300 ; adjust to your liking
    }
Return
well thing is what i need is to have the password to be sent to steam launcher window even when it dont have focus and im switching through windows and then sending enter to the steam launcher specifically, in a manner so no matter what i do said commands dont get sent to anything else as said , the pause on focus loss and continue from pause state is for as said the full batch conversion , so commands only get executed on said window if active and if not it pauses for later on refocus
Last edited by tobsto occupied on 15 Jun 2020, 15:13, 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

15 Jun 2020, 15:10

rommmcek wrote:
15 Jun 2020, 14:48
Conversion towards end of the week!

bye!
its gona be epic ! :dance:
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

15 Jun 2020, 15:29

To Login in the background you can try ControlSend,, steam password{Enter}, % Title.
Since the Edit Control seems to be always Focused it might work without specifying it!
Then of corse you don't need neither Gosub, CheckWindow nor the CheckWindow: subroutine anymore!
Can you do it by yourself?
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

16 Jun 2020, 07:50

well this is the resulting script , dont work :? >

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.

run, Devil May Cry 5_batch_mode_.bat, D:\Games\Steam
WinWaitActive, % Title:= "C:\Windows\system32\cmd ahk_exe cmd.exe",, 30

Sleep, 5000
ControlSend,, y, % Title ; alternative that works even if cmd is not active
sleep, 300
ControlSend,, {Enter}, % Title ; alternative that works even if cmd is not active
Sleep, 5000
WinWait, % Title:= "Steam Login ahk_exe steam.exe"
ControlSend,, steampassword{Enter}, % Title 
ExitApp
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

16 Jun 2020, 11:48

Last two shots in that direction:

Code: Select all

;...
WinWait, % Title:= "Steam Login ahk_exe steam.exe"
WinWaitActive, % Title
ControlSend,, steamPassword{Enter}, % Title
ExitApp
and:

Code: Select all

;...
WinWait, % Title:= "Steam Login ahk_exe steam.exe"
WinWaitActive, % Title
ControlSend,, steamPassword, % Title
sleep, 300
ControlSend,, {Enter}, % Title
ExitApp
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

16 Jun 2020, 16:53

Ultimate idea: Try to replace ControlSend,, steamPassword, % Title with:

Code: Select all

SetTitleMatchMode, RegEx
SendMessage, 0x0C,, "steamPassword", .*, % Title
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

17 Jun 2020, 04:54

dont work >

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.

run, Devil May Cry 5_batch_mode_.bat, D:\Games\Steam
WinWaitActive, % Title:= "C:\Windows\system32\cmd ahk_exe cmd.exe",, 30

Sleep, 5000
ControlSend,, y, % Title ; alternative that works even if cmd is not active
sleep, 300
ControlSend,, {Enter}, % Title ; alternative that works even if cmd is not active
Sleep, 5000
WinWait, % Title:= "Steam Login ahk_exe steam.exe"
SetTitleMatchMode, RegEx
SendMessage, 0x0C,, "steam password", .*, % Title
sleep, 300
ControlSend,, {Enter}, % Title ; alternative that works even if cmd is not active
ExitApp
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

15 Jul 2020, 04:06

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.

run, Devil May Cry 5_batch_mode_.bat, D:\Games\Steam
WinWaitActive, % Title:= "C:\Windows\system32\cmd ahk_exe cmd.exe",, 30
Sleep, 5000
ControlSend,, y{Enter}, % Title ; alternative that works even if cmd is not active
#Persistent
SetTimer, PassWandGo, 300
Return

PassWandGo:
    WinActivate, % Title:= "ahk_exe steam.exe"
    If WinActive(Title)&&!GetKeyState("Alt", "P")&&!GetKeyState("LButton", "P") {
        Clipboard:= "my password"
        Send, ^v{Sleep 90}{Enter}
        ExitApp
    }
Return

#Esc:: ExitApp ; Emergency exit
[Edit2]: Using BlockInput (rearranged) to prevent interference.
[Edit3]: Removed BlockInput and increased input speed.
Last edited by rommmcek on 20 Jul 2020, 11:39, edited 6 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

15 Jul 2020, 11:06

well that works , BUT, only issue with it is , that when i continue clicking on a different window to make it loose focus as much as possible it wont send enter to the steam launcher, i do this to make sure that it 100% gets entered , password works no matter how many times i try to make it loose focus , but the enter afterwards dont

the way ive fixed this is reduce the sleep time after password from 200 to 100 , that way theres no time for focus loss to stop the enter process in the steam launcher window


well now that wheve got both parts up to speed , the full ahk would be the finishing step, as said take your time with that my dude



p.s , btw got another issue , that ive been aiming at with this topic as well , and thats for my other ahk script i use for Doom 2016, i need the much talked about pause on game exe focus loss and continue from paused state on refocus of game exe, game ahk without requested feature here >

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
IfWinNotActive, % Title
    WinActivate, % Title
WinWaitActive, % Title,, 30
;Sleep, 5000 ; you said 30 sec. ???
Sleep, 30000 ; 30 sec. ; unclear!!!
Send, {~} ; This should work!!!
Sleep, 300 ; some time betwixt the entries (may vary form 0 to 500 ms or more)
Send, messagemode 1
sleep 300
Send, {Enter}
Sleep, 300 ; some time betwixt the entries (may vary form 0 to 500 ms or more)
Send, g_infiniteammo 1
Send, {enter}
sleep, 300
Send, {~}
sleep, 300
Send, {Enter}
sleep, 300
Send, {Enter}
sleep 300
Send, {Enter}
sleep, 300
Sleep, 40000
Send, {~} ; This should work!!!
sleep, 300
Send, {enter}
sleep, 300
Send, ai_death_FadeDelay 60000
Send, {enter}
sleep, 300
Send, breakable_NoFadeAndRemove 1
Send, {enter}
sleep, 300
Send, gore_neverFadeAndRemove 1
Send, {enter}
sleep, 300
Send, corpseManager_MaxTime 60000
Send, {enter}
sleep, 300
Send, ai_maxCorpses 60
Send, {enter}
sleep, 300
Send, corpseManager_MaxEntities 128
Send, {enter}
sleep, 300
Send, gore_maxLivingGoreEnts 5000
Send, {enter}
sleep, 300
Send, g_bloodspherescale 35f
Send, {enter}
sleep, 300
Send, g_gorebloodsphereexpanddistance 75f
Send, {enter}
sleep, 300
Send, encounterscript_globalmaxai 60
Send, {enter}
sleep, 300
Send, decal_maxdecalsinradius 40
Send, {enter}
sleep, 300
Send, decal_maxdecalgroupingradius 400.0f
Send, {enter}
sleep, 300
Send, g_goresplashjointsused 32
Send, {enter}
sleep, 300
Send, r_decalclusteringnumdecalsperjob 48
Send, {enter}
sleep, 300
Send, g_breakabledebugdecals 1
Send, {enter}
sleep, 300
Send, r_rendergatherdecalsgranularity 32
Send, {enter}
sleep, 300
Send, g_breakablefloorsplatfromceiling 1
Send, {enter}
sleep, 300
Send, r_decalLifetimeMultiplier 12
Send, {enter}
sleep, 300
Send, r_decalDistanceFadeMultiplier 7
Send, {enter}
sleep, 300
Send, r_detailDistance 25000
Send, {enter}
sleep, 300
Send, r_decalPixelThresholdFadeStart 200
Send, {enter}
sleep, 300
Send, r_decalPixelThresholdFadeEnd 180
Send, {enter}
sleep, 300
Send, r_detailFadeDistMax 24000
Send, {enter}
sleep, 300
Send, r_flaresQuality 0
Send, {enter}
sleep, 300
Send, r_foliageStartFadeDist 20000
Send, {enter}
sleep, 300
Send, r_foliageSmallFadeDistMax 25000
Send, {enter}
sleep, 300
Send, r_foliageBigFadeDistMax 25000
Send, {enter}
sleep, 300
Send, r_lightDistanceFadeMultiplier 7
Send, {enter}
sleep, 300
Send, r_shadowFadeRangeScale 7
Send, {enter}
sleep, 300
Send, r_shadowLODProjectionSizeFactor 0.25
Send, {enter}
sleep, 300
Send, r_shadowPlayerLOD 0
Send, {enter}
sleep, 300
Send, g_showPlayerShadow 1
Send, {enter}
sleep, 300
Send, p_showFootstepParticles 1
Send, {enter}
sleep, 300
Send, image_BCCompressionQuality 0
Send, {enter}
sleep, 300
Send, decal_ForceFadeOutDuration 100000
Send, {enter}
sleep, 300
Send, r_decalDistanceExtendedFadeStart 6000
Send, {enter}
sleep, 300
Send, r_staticTransparencyFadeMaxDist 6000
Send, {enter}
sleep, 300
Send, r_staticTransparencyFadeStartDist 5900
Send, {enter}
sleep, 300
Send, dp_fxLimitThirdPerson 0
Send, {enter}
sleep, 300
Send, r_shadowsDistanceFadeMultiplier 7
Send, {enter}
sleep, 300
Send, vt_lodBias -2
Send, {enter}
sleep, 300
Send, hands_FovScale 0.95
Send, {enter}
sleep, 300
Send, hands_offsetx .13
Send, {enter}
sleep, 300
Send, hands_offsetz -.03
Send, {enter}
sleep, 300
Send, hands_offsetpitch 2
Send, {enter}
sleep, 300
Send, hands_offsetyaw -2
Send, {enter}
Send, {~}
ExitApp

thanks in advance
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

15 Jul 2020, 13:01

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",, 30
Sleep, 30000
#Persistent
SetTimer, Part1, 300
Return

Part1:
WinActivate, % Title
KeyWait, Alt
KeyWait, Ctrl
BlockInput, On
If WinActive(Title) {
    Send, {~}
    Sleep, 300
    Send, messagemode 1
    sleep 300
    Send, {Enter}
    Sleep, 300
    Send, g_infiniteammo 1
    Send, {enter}
    sleep, 300
    Send, {~}
    sleep, 300
    Send, {Enter}
    sleep, 300
    Send, {Enter}
    sleep 300
    Send, {Enter}
    SetTimer, Part1, Off
    WinMinimize, % Title ; So you know when the first part is over
    BlockInput, Off
    sleep, 40000
    SetTimer, Part2, 300
}
BlockInput, Off
Return

Part2:
WinActivate, % Title
KeyWait, Alt
KeyWait, Ctrl
BlockInput, On
If WinActive(Title) {
    Send, {~}
    sleep, 300
    Send, {enter}
    sleep, 300
    Send, ai_death_FadeDelay 60000
    Send, {enter}
    sleep, 300
    Send, breakable_NoFadeAndRemove 1
    Send, {enter}
    sleep, 300
    Send, gore_neverFadeAndRemove 1
    Send, {enter}
    sleep, 300
    Send, corpseManager_MaxTime 60000
    Send, {enter}
    sleep, 300
    Send, ai_maxCorpses 60
    Send, {enter}
    sleep, 300
    Send, corpseManager_MaxEntities 128
    Send, {enter}
    sleep, 300
    Send, gore_maxLivingGoreEnts 5000
    Send, {enter}
    sleep, 300
    Send, g_bloodspherescale 35f
    Send, {enter}
    sleep, 300
    Send, g_gorebloodsphereexpanddistance 75f
    Send, {enter}
    sleep, 300
    Send, encounterscript_globalmaxai 60
    Send, {enter}
    sleep, 300
    Send, decal_maxdecalsinradius 40
    Send, {enter}
    sleep, 300
    Send, decal_maxdecalgroupingradius 400.0f
    Send, {enter}
    sleep, 300
    Send, g_goresplashjointsused 32
    Send, {enter}
    sleep, 300
    Send, r_decalclusteringnumdecalsperjob 48
    Send, {enter}
    sleep, 300
    Send, g_breakabledebugdecals 1
    Send, {enter}
    sleep, 300
    Send, r_rendergatherdecalsgranularity 32
    Send, {enter}
    sleep, 300
    Send, g_breakablefloorsplatfromceiling 1
    Send, {enter}
    sleep, 300
    Send, r_decalLifetimeMultiplier 12
    Send, {enter}
    sleep, 300
    Send, r_decalDistanceFadeMultiplier 7
    Send, {enter}
    sleep, 300
    Send, r_detailDistance 25000
    Send, {enter}
    sleep, 300
    Send, r_decalPixelThresholdFadeStart 200
    Send, {enter}
    sleep, 300
    Send, r_decalPixelThresholdFadeEnd 180
    Send, {enter}
    sleep, 300
    Send, r_detailFadeDistMax 24000
    Send, {enter}
    sleep, 300
    Send, r_flaresQuality 0
    Send, {enter}
    sleep, 300
    Send, r_foliageStartFadeDist 20000
    Send, {enter}
    sleep, 300
    Send, r_foliageSmallFadeDistMax 25000
    Send, {enter}
    sleep, 300
    Send, r_foliageBigFadeDistMax 25000
    Send, {enter}
    sleep, 300
    Send, r_lightDistanceFadeMultiplier 7
    Send, {enter}
    sleep, 300
    Send, r_shadowFadeRangeScale 7
    Send, {enter}
    sleep, 300
    Send, r_shadowLODProjectionSizeFactor 0.25
    Send, {enter}
    sleep, 300
    Send, r_shadowPlayerLOD 0
    Send, {enter}
    sleep, 300
    Send, g_showPlayerShadow 1
    Send, {enter}
    sleep, 300
    Send, p_showFootstepParticles 1
    Send, {enter}
    sleep, 300
    Send, image_BCCompressionQuality 0
    Send, {enter}
    sleep, 300
    Send, decal_ForceFadeOutDuration 100000
    Send, {enter}
    sleep, 300
    Send, r_decalDistanceExtendedFadeStart 6000
    Send, {enter}
    sleep, 300
    Send, r_staticTransparencyFadeMaxDist 6000
    Send, {enter}
    sleep, 300
    Send, r_staticTransparencyFadeStartDist 5900
    Send, {enter}
    sleep, 300
    Send, dp_fxLimitThirdPerson 0
    Send, {enter}
    sleep, 300
    Send, r_shadowsDistanceFadeMultiplier 7
    Send, {enter}
    sleep, 300
    Send, vt_lodBias -2
    Send, {enter}
    sleep, 300
    Send, hands_FovScale 0.95
    Send, {enter}
    sleep, 300
    Send, hands_offsetx .13
    Send, {enter}
    sleep, 300
    Send, hands_offsetz -.03
    Send, {enter}
    sleep, 300
    Send, hands_offsetpitch 2
    Send, {enter}
    sleep, 300
    Send, hands_offsetyaw -2
    Send, {enter}
    Send, {~}
    ExitApp
}
BlockInput, Off
Return
P.s.: Modified the script above too!
[Edit2]: Removed BlockInput command.
Last edited by rommmcek on 20 Jul 2020, 11:41, 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

16 Jul 2020, 07:43

why in parts? id rather it not do in parts but simply just pause as soon as game exe focus loss , for example me browsing for mods while game is running etc. and on refocus of game exe for the ahk script to continue from where it paused. most importantly for the ahk script to exit on game exit or it not launching at all or the script being successfully completed

you may reverse the edits you did to the steam launcher ahk script , its messed up now , if i make sure to click on a window in order for it to loose focus as test , it wont force the window active nor will it continue input , it just blocks input indefinitely and once i regain by ctrl+alt+delete and exit to desktop, it simply continues execution , yeah quite abit messed up , previous version worked great, exited properly on completed execution as well
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

16 Jul 2020, 08:19

First: Did you try it? Does it work?

You can add 50+ parts analogously, but what do you gain?
First part is less then 3 sec. Critical are 40 sec, that's why two parts. Second part is ca. 14 sec. What can browse out in 14 sec? Second part will start automatically, would you prefer to start it manually?
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

16 Jul 2020, 08:43

yes ive tried and no it dont work , meaning if i play around with my controller as a test simulating immediate focus loss on game exe while it wants to type in it wont completely input everything and just finish the ahk command, instead of like ive said to pause on focus loss and continue from where it paused on refocus of game exe



p.s thanks for the working steam launcher ahk , nice
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

16 Jul 2020, 17:25

Looks like BlockInput does not affect your (gamer?) mouse! All we can do now is entering data more quickly (I hope your game interface handles it well) to reduce possible interference, but there's no guaranty if you wildly trying to change the focus, which in his turn will be auto-restored (or would you prefer manual refocus?)!

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.

St:= ["~", "messagemode 1", "g_infiniteammo 1", "~", "~", "ai_death_FadeDelay60000"
    , "breakable_NoFadeAndRemove 1", "gore_neverFadeAndRemove 1", "corpseManager_MaxTime 60000"
    , "ai_maxCorpses 60", "corpseManager_MaxEntities 128", "gore_maxLivingGoreEnts 5000", "g_bloodspherescale 35f"
    , "g_gorebloodsphereexpanddistance 75f", "encounterscript_globalmaxai 60", "decal_maxdecalsinradius 40"
    , "decal_maxdecalgroupingradius400.0f", "g_goresplashjointsused 32", "r_decalclusteringnumdecalsperjob 48"
    , "g_breakabledebugdecals 1", "r_rendergatherdecalsgranularity 32", "g_breakablefloorsplatfromceiling 1"
    , "r_decalLifetimeMultiplier 12", "r_decalDistanceFadeMultiplier 7", "r_detailDistance 25000"
    , "r_decalPixelThresholdFadeStart 200", "r_decalPixelThresholdFadeEnd 180", "r_detailFadeDistMax24000"
    , "r_flaresQuality 0", "r_foliageStartFadeDist 20000", "r_foliageSmallFadeDistMax 25000"
    , "r_foliageBigFadeDistMax 25000", "r_lightDistanceFadeMultiplier 7", "r_shadowFadeRangeScale 7"
    , "r_shadowLODProjectionSizeFactor0.25", "r_shadowPlayerLOD 0", "g_showPlayerShadow 1", "p_showFootstepParticles 1"
    , "image_BCCompressionQuality 0", "decal_ForceFadeOutDuration 100000", "r_decalDistanceExtendedFadeStart 6000"
    , "r_staticTransparencyFadeMaxDist 6000", "r_staticTransparencyFadeStartDist 5900", "dp_fxLimitThirdPerson 0"
    , "r_shadowsDistanceFadeMultiplier 7", "vt_lodBias -2", "hands_FovScale 0.95", "hands_offsetx .13"
    , "hands_offsetz -.03", "hands_offsetpitch 2", "hands_offsetyaw -2", "~"], n:= 0

WinWait, % Title:= "DOOMx64vk ahk_exe DOOMx64vk.exe",, 30
WinActivate, % Title
WinWaitActive, % Title,, 30
Sleep, 30000
#Persistent
SetTimer, InputData, 300
Return

InputData:
    WinActivate, % Title
    If WinActive(Title)&&!GetKeyState("Alt", "P")&&!GetKeyState("LButton", "P") {
        Clipboard:= St[++n]
        Send, % "^v{Sleep 90}{Enter " ((n=1)? 0: (n=4)? 3: 1) "}"
        if (n>=St.Length())
            ExitApp
        sleep, % (n=4)? 40000: "{Sleep 90}"
    }
Return

#Esc:: ExitApp ; Emergency exit

P.s.: Modified again the script above!
Last edited by rommmcek on 20 Jul 2020, 11:39, edited 2 times in total.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 12 guests