Page 3 of 12

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 14 Jun 2020, 07:56
by rommmcek
Check the Cmd Title meticulously letter by letter!

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 09:45
by tobsto occupied
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

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 09:54
by rommmcek
Can you detect Edit controls with Spy tool in the Login window?

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 10:07
by tobsto occupied
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

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 10:11
by rommmcek
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?

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 10:17
by tobsto occupied
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:

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 10:23
by rommmcek
Thanks! Please reread my last post. I edited it.
Edit control is portion of the window where you can enter password with the keyboard.

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 10:28
by tobsto occupied
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

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 10:30
by rommmcek
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?

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 10:58
by rommmcek
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!

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 11:00
by tobsto occupied
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:

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 11:05
by tobsto occupied
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

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 11:14
by rommmcek
O.k.: There is a bug in PassWandLogin label. Wait a bit!

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 11:23
by tobsto occupied
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

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 11:29
by rommmcek
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

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 11:37
by tobsto occupied
lols , you and your "!"

ill check it out asap...gimme a few

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 11:47
by tobsto occupied
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.

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 11:57
by rommmcek
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.

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 12:08
by rommmcek
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!

Re: Request for a script that autostops commands etc. on app focus loss and continue on refocus from where it left off

Posted: 15 Jun 2020, 12:22
by tobsto occupied
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: