Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[Help] Wait for page to load before execute next command.


  • Please log in to reply
9 replies to this topic
JulieXP
  • Members
  • 93 posts
  • Last active: Jul 14 2011 06:45 PM
  • Joined: 24 Oct 2004
Hi,

I am trying to some how read the status bar to show the page is finish loading before executing the next command, but if page does not finish loading with in 10 seconds to refresh the page.

Is this doable for firefox?



I tired the code below, but does not seem to work for fire fox. Does anyone know a way around this?
---------------------------------------------------

StatusBarWait, Done, 10000
if ErrorLevel <> 0
MsgBox, The wait timed out or the window was closed.
else
MsgBox, The page is done loading.

pause

tank
  • Moderators
  • 4242 posts
  • Last active: Oct 01 2014 01:38 PM
  • Joined: 21 Dec 2007
StatusBarWait is at best hit and miss early in to my automating web pages with ahk i tried this with little success. :(

Now if you are willing to use a gui window or ie7 :evil: for your task i have a perfect solution for you.
Automation IE7 Navigation and Scripting with Tabs
I wrote this functions for use in a banking environment. based on some other similar work that had some degree of success but this function set is rock solid.

AHK can be quite frustrating in web page automation but what you need has been done before by others not just me.
also search for libcurl.... that one isnt mine but i think even tho its not the best for scraping from the screen it should work well in firefox.

of course if you need help with my scripts just ask

tank
  • Moderators
  • 4242 posts
  • Last active: Oct 01 2014 01:38 PM
  • Joined: 21 Dec 2007
example with IE 7 using the link in the previous post
COM_Init()
run iexplore.exe http://www.autohotkey.com/
WinWait,AutoHotkey,,5
sleep,1000
myPageHandle:=IE7_Get("autohotkey")
;~ MsgBox % myPageHandle
IE7_readyState(myPageHandle) ;  waits for onload event of a webpage even if an onload isnt fired
IE7_Click_Text(myPageHandle,"forum") ; cycles thru the links collection and clicksthe first text match it finds then waits for the page load to complete

IE7_Click_Text(myPageHandle,"search")
IE7_Set_DOM(myPageHandle,"search_keywords","Automation IE7 Navigation and Scripting with Tabs") ;example of filling out a form 
IE7_Button_click(myPageHandle,"search")
IE7_Click_Text(myPageHandle,"Automation IE7 Navigation and Scripting with Tabs")
MsgBox, 262192, Meet the Robinsons, There we go a full list of functions and explainations, 5
IE7_Click_Text(myPageHandle,"search")
IE7_Set_DOM(myPageHandle,"search_keywords","Automation IE7 Navigation and Scripting with Tabs") ;example of filling out a form 
IE7_Button_click(myPageHandle,"search") ; click a button labeled search and wait for the page to load
IE7_Click_Text(myPageHandle,"Wait for page to load before execute next command")
MsgBox, 262192, Meet the Robinsons, And back where we started, 5
COM_Term()
ExitApp
Please remember to dl seans "com" library there is a link in my post

Krogdor
  • Members
  • 1391 posts
  • Last active: Jun 08 2011 05:31 AM
  • Joined: 18 Apr 2008
If it's the same webpage every time, you could do an ImageSearch to try and find something on the window to see if it's loaded... Or actually, you could do an ImageSearch to look for the little "Done" word in the bottom left hand side of the screen?

Just throwing some things out there..

tank
  • Moderators
  • 4242 posts
  • Last active: Oct 01 2014 01:38 PM
  • Joined: 21 Dec 2007
the problem with that is sometimes pages call several things while loading and done can actually apear falsely loaded

JulieXP
  • Members
  • 93 posts
  • Last active: Jul 14 2011 06:45 PM
  • Joined: 24 Oct 2004
thank you tank

garry
  • Members
  • 2986 posts
  • Last active: Oct 21 2014 07:47 AM
  • Joined: 19 Apr 2005
example autohotkey login with firefox
sends userid when running wheel stops (webpage is loaded)
#persistent
USERID  =julieXP
PASSWRD =12345678

FXA=http://www.autohotkey.com/forum/login.php?redirect=index.php
IXE=%A_programfiles%\Mozilla Firefox\firefox.exe

WA=%A_screenwidth%
HA=%A_screenheight%
XN  :=(WA*99.375)/100  ;1272
YN  :=(HA*2.93 )/100   ;30

Run,%IXE% %FXA%,,max
SetTimer, FF2,500
Return
;-------------------

;--------- search running wheel firefox 2.0.0.14 ----------
FF2:
col32:=0xB2B2B2
PixelGetColor, OutputVar, XN, YN
;msgbox, 262144, COLOR, %outputvar%, 1

if outputvar=%col32%
  goto,FF
return

FF:
SetTimer,FF2,off
sleep,500
send,%USERID%
sleep,500
send,{TAB}
sleep,500
send,%PASSWRD%
send,{TAB}
sleep,500
send,{ENTER}
exitapp



engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
Just a quick note that all the interface elements in firefox are not "windows" gui elements, so commands like controlsend and StatusBarWait cannot "see" the controls.

tank
  • Moderators
  • 4242 posts
  • Last active: Oct 01 2014 01:38 PM
  • Joined: 21 Dec 2007
altho the method of filling out the form will be troublesome on some pages some forms dont start with focus in a feild .
i do like the wheel thing
but this like the status bar in ie can give you false positive loads not due to bad web page design but because if pages that load between and then redirect
you might be better off to use curl to fill out and submit web forms if you refuse to use IE :evil: or a Browser object in a GUI :roll:

keyboardfreak
  • Members
  • 217 posts
  • Last active: Sep 27 2010 07:21 PM
  • Joined: 09 Oct 2004
Here's an idea which could solve this issue. Any volunteers to implement it?

<!-- m -->http://www.autohotke... ... ml#2160792<!-- m -->