Sign in to follow this  
Followers 0
Unicornasaurus

WinWait() is failing to find identical window

6 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Though this is resolved, isn't there some sort of Forum Rule about automating logins on websites? Or helping others break said rules?


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Though this is resolved, isn't there some sort of Forum Rule about automating logins on websites? Or helping others break said rules?

Oh shoot... you are correct. In my Friday mind frame, I just saw a post with 0 replies and an easy fix.

Sorry about that

Share this post


Link to post
Share on other sites

Meh. Such a crude method that I don't even feel like deleting the code. Thread locked though.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0