Jump to content

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

Wait for page to load


  • Please log in to reply
7 replies to this topic
Shaun
  • Members
  • 67 posts
  • Last active: May 06 2011 11:18 PM
  • Joined: 11 Jul 2009
I need some help with this script it used to work but now it fails to wait for the page to load, it needs to load 3 pages and wait each time to copy text.

#include lib\com.ahk
FileDelete C:\AA2 BG Tool\bg.txt
WinActivate ahk_class XLMAIN
WinWait ahk_class XLMAIN
WinActivate
Clipboard=
Sleep 250
Send ^g
WinWaitActive Go To
Send C5{enter}
Sleep 250
send ^c
ClipWait 0.2
Save1:=Clipboard
Clipboard:=Save1
ClipWait 0.2
one:=Clipboard
Clipboard:=
Send ^g
WinWaitActive Go To
Send H5{enter}
Sleep 250
Send ^c
ClipWait 0.2
Save2:=Clipboard
Clipboard:=Save2
ClipWait 0.2
two:=Clipboard
Clipboard=
Sleep 1000
;---------------------------------------------------------------------------------------------
COM_Init()
pwb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
GETdata := "?searchquery=" one "&searchquery2=" two "&searchtable=1"
url:="http://history.anticheatinc.com/aa2/logincmp.php"
COM_Invoke(pwb, "Navigate", url GETdata) 
WinActivate
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         
   break
Sleep 500
Clipboard=
Sleep 500
Send ^a
Sleep 500
Send ^c
Clipwait 0.2
FileAppend , %Clipboard% , bg.txt
Sleep 500
Clipboard=
;--------------------------------------------------------------------------
Sleep 1000
GETdata := "?searchquery=" one "&searchquery2=" two "&searchtable=2"
url:="http://history.anticheatinc.com/aa2/logincmp.php"
COM_Invoke(pwb, "Navigate", url GETdata) 
WinActivate
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         
   break
Sleep 500
Clipboard=
Sleep 500
Send ^a
Sleep 500
Send ^c
Clipwait 0.2
FileAppend , %Clipboard% , bg.txt
Sleep 500
Clipboard=
-----------------------------------------------------------------------------
Sleep 1000
GETdata := "?searchquery=" one "&searchquery2=" two "&searchtable=3"
url:="http://history.anticheatinc.com/aa2/logincmp.php"
COM_Invoke(pwb, "Navigate", url GETdata) 
WinActivate
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         
   break
Sleep 500
Clipboard=
Sleep 500
Send ^a
Sleep 500
Send ^c
Clipwait 0.2
FileAppend , %Clipboard% , bg.txt
Sleep 500
Clipboard=
;-------------------------------------------------------------------------------
Sleep 250
WinActivate ahk_class XLMAIN
WinWait ahk_class XLMAIN
Sleep 250
Send ^x
COM_Invoke(pwb, "Quit")
COM_Term()
ExitApp



a4u
  • Guests
  • Last active:
  • Joined: --
Perhaps try switching:
[color=DarkRed]loop[/color] 

      [color=DarkRed]If[/color] (rdy:=COM_Invoke(pwb,[color=CornFlowerBlue]"readyState"[/color]) = 4) 

          

   [color=DarkRed]break[/color]
to:
[color=DarkRed]while[/color] COM_Invoke(pwb,[color=CornFlowerBlue]"busy"[/color])

	[color=DarkRed]Sleep[/color], 10
or:
[color=DarkRed]while[/color] COM_Invoke(pwb,[color=CornFlowerBlue]"readystate"[/color]) != 4

	[color=DarkRed]Sleep[/color], 10

[color=DarkRed]while[/color] COM_Invoke(pwb,[color=CornFlowerBlue]"document.readystate"[/color]) != [color=CornFlowerBlue]"complete"[/color]

	[color=DarkRed]Sleep[/color], 10


Shaun
  • Members
  • 67 posts
  • Last active: May 06 2011 11:18 PM
  • Joined: 11 Jul 2009
Thanks will give it a try, i might also look at Urldownloadtofile as the output from the page goes to a txt doc anyways.

Shaun
  • Members
  • 67 posts
  • Last active: May 06 2011 11:18 PM
  • Joined: 11 Jul 2009
If the page i am trying to download is encrypted will urldownloadtofile work?

the page is part of a database query and is decrypted when you search for information, i will give example page to what it would return.

<!-- m -->http://history.antic... ... rchtable=1<!-- m -->

All i get in my file is encrypted text.

Shaun
  • Members
  • 67 posts
  • Last active: May 06 2011 11:18 PM
  • Joined: 11 Jul 2009
I have tried a few different ways including what you posted with no success, can anyone help me with the loading of the page, i am happy with my code if i can get each page to wait until it has copied the text.

a4u
  • Guests
  • Last active:
  • Joined: --
These two snippets work for me ...
COM_Init()

pwb := COM_CreateObject([color=CornFlowerBlue]"InternetExplorer.Application"[/color])

GETdata := [color=CornFlowerBlue]"?searchquery="[/color] one [color=CornFlowerBlue]"&searchquery2="[/color] two [color=CornFlowerBlue]"&searchtable=1"[/color]

url:=[color=CornFlowerBlue]"http://history.anticheatinc.com/aa2/logincmp.php"[/color]

COM_Invoke(pwb, [color=CornFlowerBlue]"Navigate"[/color], url GETdata) 

[color=DarkRed]while[/color], COM_Invoke(pwb,[color=CornFlowerBlue]"readyState"[/color]) != 4

	[color=DarkRed]Sleep[/color], 10

[color=DarkRed]FileAppend[/color] , % COM_Invoke(pwb, [color=CornFlowerBlue]"document.documentElement.innerText"[/color]) , bg.txt

COM_Invoke(pwb,[color=CornFlowerBlue]"Quit"[/color])

COM_Release(pwb), COM_Term()
; get HTML

COM_Init()

GETdata := [color=CornFlowerBlue]"?searchquery="[/color] one [color=CornFlowerBlue]"&searchquery2="[/color] two [color=CornFlowerBlue]"&searchtable=1"[/color]

url:=[color=CornFlowerBlue]"http://history.anticheatinc.com/aa2/logincmp.php"[/color]

pwhr := COM_CreateObject( [color=CornFlowerBlue]"WinHttp.WinHttpRequest.5.1"[/color] )

COM_Invoke(pwhr, [color=CornFlowerBlue]"Open"[/color], [color=CornFlowerBlue]"GET"[/color], url GETData ) 

COM_Invoke(pwhr, [color=CornFlowerBlue]"Send"[/color])

html := COM_Invoke(pwhr, [color=CornFlowerBlue]"ResponseText"[/color])

	; extract Text

doc := COM_CreateObject([color=CornFlowerBlue]"htmlfile"[/color])

COM_Invoke(doc, [color=CornFlowerBlue]"write"[/color], html)

[color=DarkRed]FileAppend[/color] , % COM_Invoke(doc, [color=CornFlowerBlue]"documentElement.innerText"[/color]) , bg.txt

COM_Release(pwhr), COM_Release(doc), COM_Term()


Shaun
  • Members
  • 67 posts
  • Last active: May 06 2011 11:18 PM
  • Joined: 11 Jul 2009
I used the top code and in imports the information perfectly in to the file without opening a webpage, i added another script with a status bar because you can't see it doing anything and this bar closes when it is finished.

Only issue is that the format has changed but i think i can still extract the information i need, thanks for your help.

Shaun
  • Members
  • 67 posts
  • Last active: May 06 2011 11:18 PM
  • Joined: 11 Jul 2009
Can't seam to get the format the way i want it, is there anyway to maintain the format from thst website.