Holli
Holli

Reputation: 5072

Testing if a window is responsive

I have this script to run a online game, click trough the startup screens and input my password for me. Ever since the latest patch however, the %MWOStartupTime% has become rather unpredictable and this doesn't work reliably anymore. I'm suspecting the game is firing some early web requests. Or something.

So here's the question: Instead of waiting for a fixed time, can I somehow test if a given window not only exists but is responsive? That way I could loop, wait for a responsive window and start "clicking" then.

I'm also happy about alternative ideas/solutions. If it turns out I need to use the WinAPI I can rewrite it in a real programming language too.

Run, MWOClient.exe, %MWODirectory%

; Wait for the Client to launch
WinWait, MechWarrior Online,, 20
WinActivate, MechWarrior Online

; Wait until the window is responsive
Sleep, %MWOStartupTime%

; Press Escape a few times to skip the loading screens
Loop %MWOScreenLoops% {
    WinActivate, MechWarrior Online
    Sleep, %MWOScreenTime%
    SendInput {Esc}
}

; Click the password textbox
WinActivate, MechWarrior Online
Click %MWOPasswordBoxXCoord%, %MWOPasswordBoxYCoord%
Sleep 500

; Type the password
WinActivate, MechWarrior Online
SendInput %MWOPassword%
Sleep 500

; Copy the password to the clipboard in case the 
; password input fails
clipboard = %MWOPassword%

; Click login
Click %MWOPlayButtonXCoord%, %MWOPlayButtonYCoord%

Upvotes: 0

Views: 136

Answers (1)

Robert Miller
Robert Miller

Reputation: 201

Have you tried following WinActivate with WinWaitActive? You should be able to drop the Sleep command.

WinActivate, MechWarrior Online WinWaitActive, MechWarrior Online

https://www.autohotkey.com/docs/commands/WinWaitActive.htm

Upvotes: 1

Related Questions