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: 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, 09:45

yeah had one lower case in there , still wont continue on password login window tho even if focused from start

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
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"
SetTimer, PassWandLogin, 300
Return

PassWandLogin:
    If WinActive(Title) {
        Send, steam password
        sleep, 300
        Send, {Enter}
        ExitApp
    }
Return
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, 10:07

what , why?

simply put this ahk script works but will not do said requested function of pausing on focus loss and continuing on refocus where it paused >


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
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",, 30
WinActivate, % Title
WinWaitActive, % Title,, 30

Send, my steam password
sleep, 300
Send, {Enter}
ExitApp
Last edited by tobsto occupied on 15 Jun 2020, 10:12, edited 1 time in total.
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, 10:11

Looks like you don't need any help!
If you still do please answer the question and post screen shot with Login window and Spy tool when mouse is over Edit control, please!

[Edit] Additionally pleas do the following test:
1. Run the game so the Login window appears
2. Switch the focus to some other window
3. Switch the focus (manually) again to Login window
4. Can you now enter password ( via keyboard) without clicking the Login window edit control?
Last edited by rommmcek on 15 Jun 2020, 10:19, 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, 10:17

hope this helps , not sure how tho , but ok , btw not sure what you mean with edit controls


https://www17.zippyshare.com/v/tzYYO8pW/file.html


p.s if i didnt need help i wouldn'tve opened up said thread :problem:
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, 10:23

Thanks! Please reread my last post. I edited it.
Edit control is portion of the window where you can enter password with the keyboard.
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, 10:28

ive done step 1-4 and yes password field is always autoselected no matter how many times focus is lost and regained since steam autoselects it on default if you have a saved account
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, 10:30

There is Window Title mismatch: should be WinWait, % Title:= "Steam Login ahk_exe steam.exe",, 30


[Edit] Is Spy box "Control Under Mouse Position" always blank even if mouse cursor is over Password Edit control?
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, 10:58

Please do one more test (I know it's tedious but there is no other way):
1. Run the game so the Login window appears
2. Run the following Ahk script:

Code: Select all

run notepad.exe
sleep, 2000
WinActivate Steam Login ahk_exe steam.exe
WinWaitActive Steam Login ahk_exe steam.exe
        Send, steam password
        sleep, 300
        Send, {Enter}
ExitApp
P.s.: Case shouldn't matter in ahk_exe portion of the Window Title, but just as a precaution!
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, 11:00

ill try it out

@always blank question , yes it is

ok so this is how the script 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.

CoordMode, Mouse, Client
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",, 30
SetTimer, PassWandLogin, 300
Return

PassWandLogin:
    If WinActive(Title) {
        Send, steam password
        sleep, 300
        Send, {Enter}
        ExitApp
    }
Return
still after updating the steam title to as you specified still dont work

p.s tedious? fuck, to you? i can understand , this entire thing must be tedious and headache inducing as fuck , to me ? im willing to try out all variants till we get shit workin :morebeard:
Last edited by tobsto occupied on 15 Jun 2020, 11:06, 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, 11:05

yeah that one works>

Code: Select all

run notepad.exe
sleep, 2000
WinActivate Steam Login ahk_exe steam.exe
WinWaitActive Steam Login ahk_exe steam.exe
        Send, steam password
        sleep, 300
        Send, {Enter}
ExitApp
but this one works too >

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
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",, 30
WinActivate, % Title
WinWaitActive, % Title,, 30

Send, my steam password
sleep, 300
Send, {Enter}
ExitApp
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, 11:23

no rush my dude , we just gettin started here , gotta get that script pause on focus loss and continue from where it left off at pause on refocus function goin and this tied for separate exes as well for example for steam.exe and dmc5.exe
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, 11:29

I'm sorry!
You have to add #Persistent anywhere before SetTimer, PassWandLogin, 300 (Edit due to Docs)

So it should look like this:

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.

#Persistent
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"
SetTimer, PassWandLogin, 300
Return

PassWandLogin:
    If WinActive(Title) {
        Send, steam password
        sleep, 300
        Send, {Enter}
        ExitApp
    }
Return
Last edited by rommmcek on 15 Jun 2020, 11:40, 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

15 Jun 2020, 11:37

lols , you and your "!"

ill check it out asap...gimme a few
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, 11:47

ok so , ive tested it it now does wait till said steam login window is focused , BUT it still dont immediately pause the script as instantly as soon as focus is lost , ive tried by simply making sure as soon as steam login gets focused to click for example notepad so it loses focus, and the script will still continue execution and then exit itself , so not quite there yet, this thread has mainly been created due to a good friend that has noted this about ahk and scripts in general , that being why he dont like using them , since it could potentially wreak havoc , i told him there ought to be a solution and thus us being where where at, im just surprised this feature being so little sought after or even heard of, but i recon we can change that 8-)

imo should be a optional safety feature :think: of course with exceptions for parts that need to run on unfocused processes etc.
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, 11:57

Now are we where we already were. 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.

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

Sleep, 5000
        Gosub CheckWindow
ControlSend,, y, % Title ; alternative that works even if cmd is not active
sleep, 300
        Gosub CheckWindow
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, steam password
sleep, 300
        Gosub CheckWindow
Send, {Enter}
ExitApp

CheckWindow:
    While !WinActive(Title)
        Sleep, 100
Return
[Edit]: Removed one redundant check.
[Edit2]: Added two more Window checks for Cmd.
Last edited by rommmcek on 15 Jun 2020, 12:58, edited 2 times in total.
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:08

I hope above script works! [Edit]: To test it you can increase Sleep, 300 to e.g.: Sleep, 3000, so you can comfortably switch Window Focus!
More sophisticated way would be to monitor Login Window via Hook, which would stun your friend about what Ahk can do!
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, 12:22

well its already better but it continues execution , doesnt pause the script till login window has focus again , once more the testing process i do>

steam login window gets launched , then i immediately focus to notepad to make it lose focus , then i refocus steam login window and immediately unfocus by focusing notepad again, BUT it inputs the password and enters into the login window in the background

what it should be doing is when steam login window is focused it continues execution of script but as soon as it loses focus it immediately pauses where its at , and only continues from where it paused at on refocus of said login window , this should be set indefinitely or until script has been fully successful , meaning when it reaches its end and all of the scripts content has been fully successfully executed , not partially or anything else

not sure if you need hook for this, i recon would need some sort of monitoring of sorts :think:

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 21 guests