Sign in to follow this  
Followers 0
LucasM

_IEloadwait problem

10 posts in this topic

Hello comunity, i´ve started working with AutoIt and i´m getting a lot of trouble when i try to modify functions

Basically what i´ve been asked to do is, to open a Iexplorer window, make it navigate to msnbc.com (this specific page cause it got heavy flash content) and after loading... redirect that adress or just duplicate the tab.

The main problem is that sometimes, "msnbc" doesnt show "DONE" on the statusbar, so i figured out that i needed to modify that function in orded to

kill the loading process after a couple of seconds.

This way, iexplorer would do whatever i ask it to do next without waiting to complete the load right ?

how can i do that ?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi, LucasM, welcome to the forum. If you do not want to wait for the page to load at all, you would set the 4th option in IECreate to 0. Something like this:

#include <IE.au3>
_IECreate("www.msnbc.com", 0, 1, 0)
;next task

If you want it to wait a certain amount of time, but not until the page loads, look into the Sleep function in the help file.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Jlogan, that was incredibly fast. I´ve tried that and it shows me an error saying this

"C:\Program Files\AutoIt3\Include\IE.au3 (202) : ==> "Func" statement has no matching "EndFunc".:

Func _IECreate($s_Url = "about:blank", $f_tryAttach = 0, $f_visible = 1, $f_wait = 1, $f_takeFocus = 1)

>Exit code: 1 Time: 0.2092"

ive placed that under complete functional line wrote. and that error was shown.

Share this post


Link to post
Share on other sites

Can you post the exact code you use? I tested JLogan3o13's code here and it works just fine.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

im reading all the tutorials i can while posting here. i really want to keep learning bout this program. but until 3 days ago i´d never programmed anything in my life..

i ´ve started working and this are the things they asmk me to write. it´s a little bit confusing , but probably not impossible.

Share this post


Link to post
Share on other sites

The error you get may be caused by a missing quote or something like that. Hence I ask for the skript code you run.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Well we just wrote this... and it seems to work for now.

Func WaitLoad($window) ;1 a waitload le asigna window

Dim $state

Sleep(5000)

$state = ControlGetText($window, "", "msctls_statusbar321")

Sleep(2000)

If $state = "Done" OR "Done, but with errors on page" Then

Sleep(1000)

Else

EndLoad($window)

EndIf

EndFunc

Func EndLoad($window)

Sleep(2000)

Send("{ESC}")

Sleep(2000)

EndFunc

any idea of doing this in native functions ?

Share this post


Link to post
Share on other sites

ok, it doesnt work properly. Windows continue loading.. without reaching the next line

i cannot send you the code cause it wont work on your computers.

im working on layers. with an api.

Share this post


Link to post
Share on other sites

ok, it doesnt work properly. Windows continue loading.. without reaching the next line

i cannot send you the code cause it wont work on your computers.

im working on layers. with an api.

Can you not write a small reproducer that illustrates where the script is failing? If your script is not working, yet you cannot show your code, you make it nigh impossible to assist you.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#Include <WinAPI.au3>
#include <GUIConstantsEx.au3>
Dim $runAllTests=False, $runFileTests=False, $runViewTests=False, $runEditTests=False, $runFavTests=False, $runToolTests=False, $runHelpTests=False, $runPrntTests=False, $runNavTests=False, $runPlugTests=False
GUICreate("IE6 Automated Testing", 320, 300)
GUICtrlCreateLabel("This Autoit Script automates the testing of nearly all UI components, Navigation and Plugins (Adobe Flash, Adobe Reader and Java).", 10, 10, 300, 50)
$allTestsCB = GUICtrlCreateCheckbox("Run All Tests", 10, 60, 200)
$fileCB = GUICtrlCreateCheckbox("File Menu Tests", 10, 80, 200)
$editCB = GUICtrlCreateCheckbox("Edit Menu Tests", 10, 100, 200)
$viewCB = GUICtrlCreateCheckbox("View Menu Tests", 10, 120, 200)
$favCB = GUICtrlCreateCheckbox("Favorites Menu Tests", 10, 140, 200)
$toolsCB = GUICtrlCreateCheckbox("Tools Menu Tests", 10, 160, 200)
$helpCB = GUICtrlCreateCheckbox("Help Menu Tests", 10, 180, 200)
$printCB = GUICtrlCreateCheckbox("Printing Menu Tests", 10, 200, 200)
$navCB = GUICtrlCreateCheckbox("Navigation Tests", 10, 220, 200)
$plugCB = GUICtrlCreateCheckbox("Plugins Tests", 10, 240, 200)
$okbutton = GUICtrlCreateButton("OK", 180, 260, 60)
$cancelbutton = GUICtrlCreateButton("Cancel", 245, 260, 60)
GUISetState(@SW_SHOW)
GUICtrlSetState ($allTestsCB, $GUI_CHECKED )
GUICtrlSetState ($fileCB, $GUI_CHECKED )
GUICtrlSetState ($editCB, $GUI_CHECKED )
GUICtrlSetState ($viewCB, $GUI_CHECKED )
GUICtrlSetState ($favCB, $GUI_CHECKED )
GUICtrlSetState ($toolsCB, $GUI_CHECKED )
GUICtrlSetState ($helpCB, $GUI_CHECKED )
GUICtrlSetState ($printCB, $GUI_CHECKED )
GUICtrlSetState ($navCB, $GUI_CHECKED )
GUICtrlSetState ($plugCB, $GUI_CHECKED )
While 1
  $msg = GUIGetMsg()
  Select
Case $msg = $cancelbutton
  Exit
Case $msg = $okbutton
   $uiCtrlState = GUICtrlRead($fileCB, 0)
   if $uiCtrlState = $GUI_CHECKED Then
    $runFileTests=True
   Else
    $runFileTests=False
   EndIf
   $uiCtrlState = GUICtrlRead($editCB, 0)
   if $uiCtrlState = $GUI_CHECKED Then
    $runEditTests=True
   Else
    $runEditTests=False
   EndIf
   $uiCtrlState = GUICtrlRead($viewCB, 0)
   if $uiCtrlState = $GUI_CHECKED Then
    $runViewTests=True
   Else
    $runViewTests=False
   EndIf
   $uiCtrlState = GUICtrlRead($favCB, 0)
   if $uiCtrlState = $GUI_CHECKED Then
    $runFavTests=True
   Else
    $runFavTests=False
   EndIf
   $uiCtrlState = GUICtrlRead($toolsCB, 0)
   if $uiCtrlState = $GUI_CHECKED Then
    $runToolTests=True
   Else
    $runToolTests=False
   EndIf
   $uiCtrlState = GUICtrlRead($helpCB, 0)
   if $uiCtrlState = $GUI_CHECKED Then
    $runHelpTests=True
   Else
    $runHelpTests=False
   EndIf
   $uiCtrlState = GUICtrlRead($printCB, 0)
   if $uiCtrlState = $GUI_CHECKED Then
    $runPrntTests=True
   Else
    $runPrntTests=False
   EndIf
   $uiCtrlState = GUICtrlRead($navCB, 0)
   if $uiCtrlState = $GUI_CHECKED Then
    $runNavTests=True
   Else
    $runNavTests=False
    EndIf
   $uiCtrlState = GUICtrlRead($plugCB, 0)
   If $uiCtrlState = $GUI_CHECKED Then
    $runPlugTests=True
   Else
    $runPlugTests=False
    EndIf

  GUIDelete()
  ExitLoop
Case $msg = $allTestsCB
  $ctrlState = GUICtrlRead($allTestsCB, 0)
  if $ctrlState = $GUI_CHECKED Then
   GUICtrlSetState ($allTestsCB, $GUI_CHECKED )
   GUICtrlSetState ($fileCB, $GUI_CHECKED )
   GUICtrlSetState ($editCB, $GUI_CHECKED )
   GUICtrlSetState ($viewCB, $GUI_CHECKED )
   GUICtrlSetState ($favCB, $GUI_CHECKED )
   GUICtrlSetState ($toolsCB, $GUI_CHECKED )
   GUICtrlSetState ($helpCB, $GUI_CHECKED )
   GUICtrlSetState ($printCB, $GUI_CHECKED )
   GUICtrlSetState ($navCB, $GUI_CHECKED )
   GUICtrlSetState ($plugCB, $GUI_CHECKED )
  ElseIf $ctrlState = $GUI_UNCHECKED Then
   GUICtrlSetState ($allTestsCB, $GUI_UNCHECKED )
   GUICtrlSetState ($fileCB, $GUI_UNCHECKED )
   GUICtrlSetState ($editCB, $GUI_UNCHECKED )
   GUICtrlSetState ($viewCB, $GUI_UNCHECKED )
   GUICtrlSetState ($favCB, $GUI_UNCHECKED )
   GUICtrlSetState ($toolsCB, $GUI_UNCHECKED )
   GUICtrlSetState ($helpCB, $GUI_UNCHECKED )
   GUICtrlSetState ($printCB, $GUI_UNCHECKED )
   GUICtrlSetState ($navCB, $GUI_UNCHECKED )
   GUICtrlSetState ($plugCB, $GUI_UNCHECKED )
  EndIf
  ;ExitLoop
    Case $msg = $GUI_EVENT_CLOSE
       Exit
  EndSelect
WEnd
GUIDelete()
Global $Paused
HotKeySet("{F7}","Terminate")
HotKeySet("{F5}", "Pause")
$ieWinStart = "about:blank - Microsoft Internet Explorer";
$iewin = "Windows Internet Explorer"
$ieFileOpen = "Open"
SplashTextOn("Beginning IE8 Tests", "Attempting to load IE8", 300, 100, -1, 0, 4)
if not Run(@ProgramFilesDir & "Internet Explorer 8iexplore.exe about:blank") Then
SplashOff()
;MsgBox(4096, "Error", "Path to IE6 not found. Make sure the IE6 Layer is Activated!")
Exit
EndIf
WinWaitActive ($iewin)
$ie6Handle = WinGetHandle($ieWinStart)
If @error Then
SplashOff()
    ;;MsgBox(4096, "Error", "Could not find the correct window")
EndIf
Opt("WinTitleMatchMode", 1)
SplashTextOn("Beginning IE8 Tests", "Setting IE8 for the Tests...", 300, 100, -1, 0, 4)
Sleep(2000)
NavigateUsingAddr("www.google.com","window")
WinWait("Google")
Sleep(2000)
Send("!t")
Sleep(2000)
Send("o")
Sleep(2000)
SplashTextOn("Beginning IE8 Tests", "Setting IE8 for the Tests...: Waiting Internet Options", 300, 100, -1, 0, 4)
WinWait("Internet Options")
SplashTextOn("Beginning IE8 Tests", "Setting IE8 for the Tests...: Found Internet Options", 300, 100, -1, 0, 4)
Sleep(1000)
Send("!c")
Sleep(1000)
Send("{TAB 15}")
sleep(3000)
Send("{ENTER}")
Sleep(2000)
Send("{TAB 15}")
Sleep(3000)
Send("{RIGHT 2}")
sleep(1000)
Send("{TAB 1}")
sleep(1000)
Send("{UP 3}")
Sleep(1000)
Send("{TAB 5}")
Sleep(2000)
Send("{ENTER}")
Sleep(1000)
WinWait("Pop-up Blocker Settings")
Send("{TAB 6}")
Sleep(3000)
Send("{UP 2}")
Sleep(1000)
ControlCommand("Pop-up Blocker Settings", "Show &Information Bar when a pop-up is blocked.", 5417, "UnCheck")
Sleep(2000)
Send("{ENTER}")
Sleep(1000)
Send("{TAB 3}")
Sleep(500)
Send("{ENTER}")

If WinExists("Set Up Windows Internet Explorer 8")Then
Sleep(3000)
Send("{ESC}")
Sleep(2000)
EndIf
If WinExists("Internet Explorer")Then
  Send("!a")
  Sleep(2000)
  Send("!n")
  Sleep(2000)
EndIf
If WinExists("Internet Explorer Security")Then
Send("!s")
Sleep(2000)
Send("!a")
Sleep(2000)
EndIf
;Navigate to a site so there is something to print
NavigateUsingAddr("www.google.com", $ie6Handle)
Sleep(2000) ; give some time for the site to load.
Opt("WinTitleMatchMode", 2)
if $runFileTests Then
SplashTextOn("Running File Menu Tests", "File Menu Tests", 300, 100, -1, 0, 4)
FileMenuTests($ie6Handle)
SplashOff()
EndIf
if $runEditTests Then
SplashTextOn("Running Edit Menu Tests", "Edit Menu Tests", 300, 100, -1, 0, 4)
Sleep(3000)
EditMenuTests($ie6Handle)
SplashOff()
EndIf
if $runViewTests Then
SplashTextOn("Running View Menu Tests", "View Menu Tests", 300, 100, -1, 0, 4)
ViewMenuTests($ie6Handle)
SplashOff()
EndIf
if $runFavTests Then
SplashTextOn("Running Favorites Menu Tests", "Favorites Menu Tests", 300, 100, -1, 0, 4)
FavoritesMenuTests($ie6Handle)
SplashOff()
EndIf
if $runToolTests Then
SplashTextOn("Running Tools Menu Tests", "File Tools Tests", 300, 100, -1, 0, 4)
ToolsMenuTests($ie6Handle)
SplashOff()
EndIf
if $runHelpTests Then
SplashTextOn("Running Help Menu Tests", "Help Menu Tests", 300, 100, -1, 0, 4)
HelpMenuTests($ie6Handle)
SplashOff()
EndIf
if $runPrntTests Then
SplashTextOn("Running IE8 Printing Tests", "Running IE8 Print Function Tests", 300, 100, -1, 0, 4)
Sleep(1000)
;Navigate to a site so there is something to print
NavigateUsingAddr("www.google.com", $ie6Handle)
Sleep(5000) ; give some time for the site to load.
PrintingTest($ie6Handle)
Sleep(5000)
SplashOff()
EndIf
if $runNavTests Then
SplashTextOn("Running IE8 Navigation Tests", "Running IE8 Navigation Tests", 300, 100, -1, 0, 4)
NavigationTests($ie6Handle)
Sleep(5000)
SplashOff()
EndIf
If $runPlugTests Then
SplashTextOn("Running IE8 Plugins Tests", "Runnning IE8 Plugins Tests", 300, 100, -1, 0, 4)
PluginTests($ie6Handle)
Sleep(5000)
SplashOff()
EndIf
SplashTextOn("Running IE8 Tests", "Selected Tests are Completed!", 300, 100, -1, 0, 4)
Sleep(6000)
SplashOff()
WinClose($ie6Handle)
;DONE
Func NavigateUsingOpen($url)
Send("^o")
WinWait($ieFileOpen)
Sleep(3000)
Send($url, 1)
Sleep(3000)
Send("{ENTER}")
EndFunc
Func NavigateUsingAddr($url, $window)
Sleep(2000)
ControlFocus($window, "", "[CLASS:ComboBox; INSTANCE:1]")
Sleep(1000)
Send("!d")
Sleep(1000)
Send($url, 1)
Sleep(1000)
Send("{ENTER}")
Sleep(2000)
EndFunc
Func FileMenuTests($window)
  
    SplashTextOn("Running File Menu Tests", "File->New Tab", 300, 100, -1, 0, 4)
;File->New Tab
Send("^t")
WinWait("New Tab")
NavigateUsingAddr("altavista.com", $window)
EndLoad($window)
sleep(1000)
Send("^t")
WinWait("New Tab")
NavigateUsingAddr("wikipedia.org", $window)
    EndLoad($window)
sleep(1000)
Send("^t")
WinWait("New Tab")
NavigateUsingAddr("taringa.net", $window)
EndLoad($window)
sleep(1000)
Send("^t")
WinWait("New Tab")
NavigateUsingAddr("mercadolibre.com.ar", $window)
    EndLoad($window)
sleep(1000)
   While WinExists("Yahoo! Search - Web Search - Windows Internet Explorer")
  Send("^w")
  Sleep(3000)
WEnd

SplashTextOn("Running File Menu Tests", "File->Duplicate Tab", 300, 100, -1, 0, 4)
Sleep(1000)
;File->Duplicate Tab
Send("^k")
If WinExists("Google")then
   Sleep(1000)
   NavigateUsingAddr("altavista.com", $window)
   EndLoad($window)
   Else
  
  
    EndIf
   
If WinExists("Yahoo! Search - Web Search - Windows Internet Explorer")then
   Send("^k")
    EndIf

If WinExists("Yahoo! Search - Web Search - Windows Internet Explorer")then
   NavigateUsingAddr("wikipedia.org", $window)
   EndLoad($window)
Endif 

If WinExists("Wikipedia - Windows Internet Explorer")then
   Send("^k")
    Endif

If WinExists("Wikipedia - Windows Internet Explorer")then
      NavigateUsingAddr("taringa.net", $window)
   EndLoad($window)
    EndIf

If WinExists("Taringa! - Inteligencia Colectiva - Windows Internet Explorer")then
   Send("^k")
    Endif

If WinExists("Taringa! - Inteligencia Colectiva - Windows Internet Explorer")then
  NavigateUsingAddr("mercadolibre.com.ar", $window)
  EndLoad($window)
    EndIf
   
If WinExists("Mercadolibre Argentina - Donde comprar y cender de todo   - Windows Internet Explorer")Then
    EndLoad($window)
    EndIf

While WinExists("Yahoo! Search - Web Search - Windows Internet Explorer")
  Send("^w")
  Sleep(3000)
WEnd


  




;~  AND THE ENDLOAD FUNCTION
;~ Func WaitLoad($window)  ;1 a waitload le asigna window
;~    $state = ControlGetText($window, "", "msctls_statusbar321")
;~   Dim $state                                                                <------------------- THIS FUNCTION DIDNT WORK EITHER.
;~  Sleep(5000)
;~  Sleep(2000)
;~  If $state = "Done" OR "Done, but with errors on page" Then
;~    Sleep(1000)
;~  Else
;~    EndLoad($window)
;~  EndIf
;~ EndFunc
;~ Func EndLoad($window)
;~    Sleep(2000)
;~    Send("{ESC 5}")
;~    Sleep(4000)
;~ EndFunc

I hope this is the way to post it.. otherwise ill make a mess here. xD

the problem seemed to be the webpages i was trying to load... they were too heavy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0