AutoHotkey Community

It is currently May 27th, 2012, 10:07 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: October 13th, 2004, 9:35 am 
I have just started trying to use AutoHotKey and have tried running one of the tutorial examples to oepn a webpage and detect when it is finished loading. Each time I get "The wait timed out or the window was closed." message

The script is:
----
Run, www.yahoo.com
WinWait, Yahoo! - Microsoft Internet Explorer
WinActivate
StatusBarWait, Done, 10
if ErrorLevel <> 0
MsgBox, The wait timed out or the window was closed.
else
MsgBox, The page is done loading.
----
I tried increasing the time in StatusBarWait to 30 even 60 but still the same message.

I am using XP but have also tried on W2000 with the same result.

How do I get the StatusBarWait function to wait till the "Done" message shows in IE and work as expected?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 13th, 2004, 10:35 am 
Hi Guest (Please think about to use a nick(name) next time. Thx)
As you can see in the help all parameters of the SBW command are optional:

StatusBarWait [, BarText, Seconds, Part#, WinTitle, WinText, Interval, ExcludeTitle, ExcludeText]

As your approach is to detect the time it needs to finish loading the page a preset timing out seems not the best idea.

Have a try with:
StatusBarWait, Done

8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 13th, 2004, 11:58 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Quote:
Each time I get "The wait timed out or the window was closed." message
I see another possible problem: If the mouse cursor happens to be hovering over a link as the page appears, the "Done" message might never appear in the status bar. I've going to update the example so that it moves the mouse to 0, 0:

Run, www.yahoo.com
MouseMove, 0, 0
....

You could minmize or alt-tab away from the window like this:
...
WinWait, Yahoo! - Microsoft Internet Explorer
WinMinimize
StatusBarWait, Done, 10
WinActivate
....

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 13th, 2004, 11:32 pm 
Thanks Bobo and Chris for your replies.

The page that I am loading runs a php script which takes some time to complete.

Chris I tried your suggestion removing the seconds parameter from StatusBarWait but it still times out. I think perhaps it has a default value.
Have even tried "StatusBarWait, Done, 1000" but it still times out.

Chris tried the MouseMove, 0, 0 which is a good idea but that did not solve the problem.

Furthe help would be appreciated

Freddo


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2004, 2:44 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
When StatusBarWait finishes, what is its ErrorLevel? As stated in the help file:
Quote:
ErrorLevel is set to 1 if the command times out before a match could be found in the status bar. It is set to 2 if the status bar could not be accessed. It is set to 0 if a match is found.


Also, perhaps the "done" message does not appear in some cases. If this is true, you could try using "WinGet, OutputVar, ControlList", WinGetText, ControlGetText, or some other trick to detect when the web page has actually filled up with the contents you expect.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 14th, 2004, 3:39 am 
Thanks for your response Chris. ErrorLevel is always 2 when it quits before the the "Done" appears in the status bar. So this would suggest the status bar is not recognised or can't be access for some reason. I wonder why?

Will have a look at the other commands you mentioned


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 15th, 2004, 6:41 am 
Offline

Joined: October 12th, 2004, 11:34 pm
Posts: 74
Location: São Paulo ,Brazil
just a suggestion:
A script monitoring statusbar and showing/updating the text in a window may help you to debug the script.
Something like

Code:
Progress , M CtLime CwBlack FS12 W200 Y-27 ZB0 ZY1, XXXX,,statusmon

Loop
{
     StatusBarGetText, ?status, 1, ahk_class IEFrame
     StringSplit, ?status, ?status, %A_Space% ;is it necessary?
     Progress , ,%?status%
     Sleep, 300
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 15th, 2004, 9:39 pm 
If you can explain why you want to wait for the page to load maybe there is a better way to achieve what you want.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2004, 1:09 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Thanks; the above are good suggestions. In case it's a bug, I've asked Freddo via e-mail to let me know he can't get the StatusBarWait command to recognize the "Done" message even though Window Spy can see it in the status bar.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 12th, 2004, 1:23 am 
Any update on StatusBarWait or StatusBarGetText bug?

Ahk is having trouble accessing text on the StatusBar for some unknown reason. My error code is always 2. I have tried using it in a number of different windows. (paint, explorer, notepad, etc). I have tried it on different computers.
I have installed the latest version of Ahk.

thanks,

Anatoly

P.S. In my case, I need it so that I can download a strectch of maps from mapquest for my trips, whereby ahk would save the map picture AFTER it is downloaded (i.e. StatusBar = "Done") then advance to the next one, save after "Done" etc.etc.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2004, 2:21 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Quote:
Any update on StatusBarWait or StatusBarGetText bug?
I haven't been able to reproduce it yet. StatusBarWait will stop waiting and produce an ErrorLevel of 2 in the following cases:

1) The window or its status bar no longer or exists, or is destroyed and recreated. For example, if you run the following test script then launch Notepad, the script should stay running until you close Notepad, at which time an ErrorLevel of 2 is produced:

WinWait, Untitled - Notepad
StatusBarWait, aaa
MsgBox ErrorLevel %ErrorLevel%

2) The window does not respond to certain messages within a timeout period (I can send you a revised version to see if increasing the timeout helps).

3) The memory area of the status bar could not be read (probably rare).

Thanks for reporting it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2004, 1:59 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I've updated the installer with the following change. Please let me know if it makes any difference for you:

Fixed StatusBarGetText and StatusBarWait: If the system was under heavy load, sometimes they would give up too soon and set ErrorLevel to indicate a failure.

Edit: Fixed typo.


Last edited by Chris on November 14th, 2004, 6:43 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2004, 11:18 pm 
Nov13,04
thanks for trying but it still is not working.
1) I downloaded the installer from the download page (Nov 9) ver.1023.
Is this the one that you said you had updated?
(because the date is obviously a few days old)
2) I tried running my simple test script with it. Here it is:
;ahk test2\\
2::
{
StatusBarGetText, var,2
MsgBox, StatusBarText - Part II %var%
}
return

Run Notepad and press 2
It should return the Text in PArt#2 pf Notepad "Ln 1, Col 1"

It doesn't do it for me.

It returns just the message StatusBarText - Part II.
%var% is not holding anything.

Anatoly


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2004, 12:04 am 
Offline

Joined: October 12th, 2004, 11:34 pm
Posts: 74
Location: São Paulo ,Brazil
Hi, anatoly
Could you test this script?
It is for iExplorer windows and it is working here.
Change sounds paths if needed.
Code:
SetTitleMatchMode, 1
DetectHiddenText, on
DetectHiddenWindows, on

Loop
{
   IfWinNotExist, ahk_class IEFrame
      Return
   StatusBarWait, Done, , , ahk_class IEFrame
   If ErrorLevel = 0
   {
      SoundPlay, c:Windows\Media\ding.wav
      Loop
      {
         StatusBarGetText, ?current_status, , ahk_class IEFrame
         If ?current_status = Done
         {
            Sleep, 100
            Continue
         }
         Else
            Break
      }
   }
   Else
      SoundPlay, c:\Windows\Media\notify.wav, Wait
}



edit: you must use only one iexplorer window


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2004, 1:21 am 
Offline

Joined: September 2nd, 2004, 1:08 am
Posts: 124
Location: Sunnyvale
anatoly_larkin wrote:
Nov13,04
thanks for trying but it still is not working.
1) I downloaded the installer from the download page (Nov 9) ver.1023.
Is this the one that you said you had updated?
(because the date is obviously a few days old)
2) I tried running my simple test script with it. Here it is:
;ahk test2\\
2::
{
StatusBarGetText, var,2
MsgBox, StatusBarText - Part II %var%
}
return

Run Notepad and press 2
It should return the Text in PArt#2 pf Notepad "Ln 1, Col 1"

It doesn't do it for me.

It returns just the message StatusBarText - Part II.
%var% is not holding anything.

Anatoly


Anatoly, I am using the 1023 version and I made one small change to your script and then it worked.

Code:
;ahk test2\\
2::
{
   StatusBarGetText, var,2,Untitled - Notepad
   MsgBox, StatusBarText - Part II %var%
}
return


See how I've added the WinTitle to the StatusBarGetText command?

_________________
I am he of whom he speaks!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Google [Bot], Maestr0, Yahoo [Bot] and 63 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group