Jump to content

WinWait() is failing to find identical window


Recommended Posts

Hey Guys!

Just started using AutoIt recently, and am having a blast making small projects here and there. I've run in to an issue though with my latest project.

Basically what it does is logs in to a form and submits some text. I'll outline when the project fails:

Instance 1:

Go To Login Page -> Type in Login Information -> hit submit -> Message pops up that user already has session -> Press enter -> Wait for "Menu" window to pop up -> Close "Menu" window -> Redirect main browser to new page and enter more text

Now, Instance 2: (This is where it fails)

Go To Login Page -> Type in Login Information -> hit submit -> Wait for "Menu" window to pop up.....

For some reason, even though the "Main Menu" window is titled exactly the same, the script only proceeds when the message about an existing session pops up. I've used WinList() to output all of the window titles to a text file, and then compared the two "Main Menu" windows and the only thing that's different between them is the handle, otherwise the titles are identical.

Here's the code that I have that it's stalling on:

WinWaitActive("Logon - Windows Internet Explorer")
WinActivate("Logon - Windows Internet Explorer")
Send(GuiCtrlRead($txtUsername) & "{TAB}" & GuiCtrlRead($txtPassword) & "{TAB}{ENTER}")
WinWaitActive("Windows Internet Explorer","There is active session for user",7000)
If WinActive("Windows Internet Explorer","There is active session for user") then
  Send("{ENTER}")
EndIf
WinWait("Main Menu","")
WinClose("Main Menu")
_IENavigate($newpage)
Edited by Unicornasaurus
Link to comment
Share on other sites

Hi Unicornasaurus,

Welcome to the forums.

When you are calling WinWaitActive() for the active session, you are giving that a timeout of 7000. This is in seconds, not milliseconds. So the script would probably continue if you were willing to wait the roughly 2 hours you told it to wait :) You probably meant for it to only wait 7 seconds. Making that minor change will probably fix the issue.

Link to comment
Share on other sites

Hi Unicornasaurus,

Welcome to the forums.

When you are calling WinWaitActive() for the active session, you are giving that a timeout of 7000. This is in seconds, not milliseconds. So the script would probably continue if you were willing to wait the roughly 2 hours you told it to wait :) You probably meant for it to only wait 7 seconds. Making that minor change will probably fix the issue.

Oh man. What a facepalm moment. I can't believe I overlooked that! Thank you! I'm so used to measuring in milliseconds.

Case closed!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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