AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
JulieXP



Joined: 24 Oct 2004
Posts: 49

PostPosted: Sat May 31, 2008 10:47 am    Post subject: [Help] Wait for page to load before execute next command. Reply with quote

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
_________________
Free phpBB3 Forum Remotely Hosted
Back to top
View user's profile Send private message Visit poster's website
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Sat May 31, 2008 12:24 pm    Post subject: Reply with quote

StatusBarWait is at best hit and miss early in to my automating web pages with ahk i tried this with little success. Sad

Now if you are willing to use a gui window or ie7 Evil or Very Mad 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
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Sat May 31, 2008 12:46 pm    Post subject: Reply with quote

example with IE 7 using the link in the previous post
Code:

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
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1145
Location: The Interwebs

PostPosted: Sat May 31, 2008 6:07 pm    Post subject: Reply with quote

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..
Back to top
View user's profile Send private message AIM Address
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Sat May 31, 2008 6:43 pm    Post subject: Reply with quote

the problem with that is sometimes pages call several things while loading and done can actually apear falsely loaded
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
JulieXP



Joined: 24 Oct 2004
Posts: 49

PostPosted: Sun Jun 01, 2008 2:38 am    Post subject: Reply with quote

thank you tank
_________________
Free phpBB3 Forum Remotely Hosted
Back to top
View user's profile Send private message Visit poster's website
garry



Joined: 19 Apr 2005
Posts: 1186
Location: switzerland

PostPosted: Mon Jun 02, 2008 8:09 pm    Post subject: Reply with quote

example autohotkey login with firefox
sends userid when running wheel stops (webpage is loaded)
Code:
#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

Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Mon Jun 02, 2008 8:31 pm    Post subject: Reply with quote

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.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Mon Jun 02, 2008 9:40 pm    Post subject: Reply with quote

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 Very Mad or a Browser object in a GUI Rolling Eyes
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
keyboardfreak



Joined: 09 Oct 2004
Posts: 143
Location: Budapest, Hungary

PostPosted: Mon Aug 25, 2008 7:31 pm    Post subject: Reply with quote

Here's an idea which could solve this issue. Any volunteers to implement it?

http://www.autohotkey.com/forum/post-216079.html#2160792
Back to top
View user's profile Send private message
keyboardfreak



Joined: 09 Oct 2004
Posts: 143
Location: Budapest, Hungary

PostPosted: Mon Aug 25, 2008 8:00 pm    Post subject: Reply with quote

keyboardfreak wrote:
Here's an idea which could solve this issue. Any volunteers to implement it?


Never mind. I did it: http://www.autohotkey.com/forum/viewtopic.php?t=35056
Back to top
View user's profile Send private message
LordOfTheFiles



Joined: 28 Oct 2008
Posts: 3

PostPosted: Tue Oct 28, 2008 12:39 am    Post subject: Reply with quote

I had this problem a couple years ago when I was an AHK newbie. This question addresses the crucial issue of reliably monitoring "pagecomplete" status in FireFox & other browsers. There are many ways to monitor depending on whether or not you are visibly echoing the results back to your browser, or maybe programatically gathering data. Most of you will keep the window focused during your data-mining procedures, at least until your procedure is set in stone. The problem with webpages & sites is they are constantly changing, and ofttimes you must change your scripts to keep pace. Some very good uses of this function are gathering financial data for investments, contact information for advertising, etc.

It's never a good idea to try to monitor a moving target (FireFox "throbber") with code. The throbber graphics must be replaced in ForeFox's UserChrome folder. It consists of two graphics: an animated gif that throbs when firefox is busy and a standard gif when it is idle. There is a site that addresses this issue. The best way to do this is to use one black image and one white image, each 16 x 16 pixels. Customize your menu so that the images will be to the far upper left of your screen - then the position will never change with window size.

Because you will use this feature often, you must write a function and place it at the bottom of the script, and call it when you need it. I use AceText to drag-n-drop all my custom functions into my scripts.

If you do this, you will not need GreaseMonkey or anything else to reliably monitor pagecomplete status in FireFox. Best of all, the function is very short, and works 100% of the time. I have been using it for about two years now with peerless success. Here is the function, which you will put at the bottom of your script:

PixelChange(X,Y,Color1)
{
Sleep, 100 ;creates initial delay for page to go busy
Loop ;continually monitors until color change
{
PixelGetColor, Color, %X%, %Y%
if (Color = Color1)
break ; resumes script when color changes
}
}

;Here is the function call, which you will put in your script

;FireFoxDone:
PixelChange(15,41,0x000000)
_________________
Better a diamond with a flaw than a pebble without.
Back to top
View user's profile Send private message
icyfenix
Guest





PostPosted: Thu Nov 20, 2008 6:17 pm    Post subject: throbber change? Reply with quote

I'm having problems finding anything that will help me change the throbber

I'm running Vista home premium and I don't see anything but an example userChrome thingy.
Back to top
LordOfTheFiles



Joined: 28 Oct 2008
Posts: 3

PostPosted: Thu Dec 04, 2008 2:24 pm    Post subject: Reply with quote

Try this link. It describes the procedure for changing the FireFox throbber graphics.

http://www.zerosign.net/?p=61
_________________
Better a diamond with a flaw than a pebble without.
Back to top
View user's profile Send private message
LordOfTheFiles



Joined: 28 Oct 2008
Posts: 3

PostPosted: Thu Dec 04, 2008 7:26 pm    Post subject: Reply with quote

Here is what I put at the top of my userChrome.css file:

#navigator-throbber
{
list-style-image : url("FireFoxIdle.gif") !important;
}
#navigator-throbber[busy="true"]
{
list-style-image : url("FireFoxBusy.gif") !important;
}

The filenames in quotes must match the names of the two graphics you are using to represent idle & busy states.

When you finish this, you need to customize your menu to anchor the new "throbber" in the upper left corner of the screen. When this is done, you will have an area of pixels that will change between white & black for busy & idle conditions.

Important: If you have ever restored your personalized firefox application data by simply dropping the entire folder into a new installation, you may have multiple profiles, which may confuse firefox and cause this to not work. Make SURE you are in the chrome folder that firefox is currently looking to.

You may have to manually delete and/or uninstall firefox & start from scratch. It is much better to see only one Profile folder.
_________________
Better a diamond with a flaw than a pebble without.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group