Jump to content

Winwait for winexist


kjcdude
 Share

Recommended Posts

I need to figure out how to wait for a window to exist.

The window pops up in the background, and it can take a few seconds to popup.

Right now i just have it sleep for a few seconds then force activate it, but i would feel more confident if there is a more secure version.

Link to comment
Share on other sites

you can also switch the 'run' command with 'RunWait' which will have the same results :P

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

Hello Armand,

you can also switch the 'run' command with 'RunWait' which will have the same results :P

Do you have an example of this? My understanding of RunWait is that it will pause the script until the process is closed.

;~ Runs an external program and pauses script execution until the program finishes.
RunWait( "notepad.exe" )
ConsoleWrite( "Script execution will now continue..." & @CRLF)

Zach...

Link to comment
Share on other sites

and as i understand from his question he doesn't need it to continue while he is waiting :P

PWNED!

Edited by Armand

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

PWNED!

Indeed. My understanding is that he needs to do something with the window that belongs to the launched process.

I took Emperor's working example and replaced 'Run' with 'RunWait' as you suggested. Then I ran it with debug mode turned on.

Notepad appears and the debug shows that the script has paused here:

Line: @error-@extended: Line syntax
0001: 0-0: #AutoIt3Wrapper_run_debug_mode = Y
0002: 0-0: RunWait("notepad.exe")

It does not resume until I close that instance of Notepad. Once I do that, the script pauses on this line:

0006: 0-0: WinWait("Untitled")

It does not resume until I manually open a new instance of Notepad.

These behaviors do not manifest in the original example. This means one of two things:

1 ) My implementation of 'RunWait' is incorrect

2 ) RunWait will not have the same result regardless of implementation.

I don't mean to beleaguer the point; I'm just interested in seeing how you were able to do it.

Zach...

Link to comment
Share on other sites

and as i understand from his question he doesn't need it to continue while he is waiting :P

PWNED!

anyhow since we're playing with it... and i am so freakin' sleepy... it's 9am here and i've been up all night with my stupid script!

Opt("WinTitleMatchMode", 4)

$proc = Run("Notepad.exe", "", @SW_SHOW,7)
While 1
    If WinWaitActive("Untitled") = 1 Then ExitLoop
;~ Sleep(1000); in case it takes that process a while to load...
WEnd

Send("Not PWND, was too damn tired to PWN :)",1)

While WinExists($proc)=1    
WEnd

Exit

___________________

just in case you are realy wondering, 'runwait' runs a process and holds the script untill the child process doesn't exists anymore!

Edited by Armand

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

Hello 'kjcdude',

Well the program is actually launched from another program, so i have no control over how it opens.

Right before it opens my script presses enter then waits 10 seconds and forces the new window to come to the front.

Emperor's suggestion should still be valid in your scenario. Simply remove 'Run( "notepad.exe" )' from the example and replace window titles as appropriate. Let us know if it works.

Zach...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...