Sign in to follow this  
Followers 0
logikal16

IE quick question

16 posts in this topic

Hey guys!

Let me get started... all I want to do is load a page, such as mail.yahoo.com. The instant this page finishes loading data, It will enter my username and password and submit it. The way I currently have it is so that the script Sleep()s for a couple seconds before entering the user information, but it doesn't work depending on the user's connection.

So far I have something like this:

Run("C:\Program Files\Internet Explorer\iexplore.exe")

Sleep(5000) ;<---wait until browser loads up

Send("{ESC}") ;<---stop loading any startup page

Send("!d") ;<---goto the address bar

Send("http://mail.yahoo.com")

Send("{ENTER}")

Sleep(10000) ;<---THIS IS MY QUESTION

How do I go about replacing Sleep(10000) to detecting when the browser actually finishes loading? Sorry, I'm new at this... :( Thanks in advance.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

if you want to try out the new beta, there is a ton of stuff you can do, including full form manipulation.

$obj.ready tells if it is done

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

$obj = _IE_connect("http://mail.yahoo.com")

$obj.document.login_form.login.value = "name"
$obj.document.login_form.passwd.value = "password"
$obj.document.login_form.submit.click()

Func MyErrFunc()
   $HexNumber=hex($oMyError.number,8)
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
               "Description is: " & $oMyError.description & @CRLF & _
               "Number is: " & $HexNumber & @CRLF & _
               "Source: " & $oMyError.source & @CRLF & _
               "Scriptline: " & $oMyError.scriptline & @CRLF & _
               "Windescription is: " & $oMyError.windescription ,5)
Endfunc

Func _IE_connect($url = "www.autoitscript.com")
   Dim $ObjShell = ObjCreate ("Shell.Application")
   Dim $ObjShellWindows = $ObjShell.Windows (); collection of all ShellWindows (IE and File Explorer)
   Global $ObjIE
   
   For $Window in $ObjShellWindows
      If StringInStr($window.LocationURL, $url) > 0 Then
         $ObjIE = $Window
         ExitLoop; We found it...
      Else
         $ObjIE = 0
      EndIf
   Next
   
   If isObj ($ObjIE) Then
      ConsoleWrite("--> $ObjIE now points to an IE Instance connected" & @CR)
   Else
      $ObjIE = ObjCreate ("InternetExplorer.Application")
      
      With $ObjIE
      .Visible = True
      .Navigate ($url)
      Do
         Sleep(50)
      Until .ReadyState = 4
      EndWith
      ConsoleWrite("--> No IE instance was found connected so made one" & @CR)
   EndIf
   Return $ObjIE
EndFunc ;==>_IE_connect

also check out

http://www.autoitscript.com/forum/index.php?showtopic=12030

you can also wait for the statusbar text to say Done,

or I like to change the title, and wait for the page to change to the new title.

For full control you will want the features included only in the current beta atm.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Wow, that was pretty fast... Let me look at it for a minute and see if it makes sense... thanks

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

if you don't want to use the new beta (which I am pushing a bit too much,):

Run('C:\Program Files\Internet Explorer\iexplore.exe "http://mail.yahoo.com"')
; enter your name and pass.
winwait("Yahoo","Done")
WinSetTitle("Yahoo", "", "Waiting for page")
Send("{ENTER}")
winwait("Yahoo","Done"); set to the title that should come up.
; rest of code
Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Holy jeez, the posts keep coming... and right when i was about to reply to the 1st reply :(

Share this post


Link to post
Share on other sites

if you don't want to use the new beta (which I am pushing a bit too much,):

Run('C:\Program Files\Internet Explorer\iexplore.exe "http://mail.yahoo.com"')
; enter your name and pass.
winwait("Yahoo","Done")
WinSetTitle("Yahoo", "", "Waiting for page")
Send("{ENTER}")
winwait("Yahoo","Done"); set to the title that should come up.
; rest of code

<{POST_SNAPBACK}>

LOL I dont think you are pushing it too much. Once I went to beta I have never gone back. The onlything I dont like about the beta installer is I cant tell it to just install as if it wasnt beta. I dont get the choice where it installs to. (Maybe a dev will see this :()

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

LOL I dont think you are pushing it too much. Once I went to beta I have never gone back. The onlything I dont like about the beta installer is I cant tell it to just install as if it wasnt beta. I dont get the choice where it installs to. (Maybe a dev will see this :()

JS

<{POST_SNAPBACK}>

OK, why do you have 2 instances of winwait("Yahoo","Done") ?

And also, hypothetically... let's say that if you enter the Yahoo login correctly, It opens up a new window with the address of Google. How would the code be different? (assuming that the script continued after the Google page loaded entirely)

Edited by logikal16

Share this post


Link to post
Share on other sites

OK, why do you have 2 instances of winwait("Yahoo","Done") ?

And also, hypothetically... let's say that if you enter the Yahoo login correctly, It opens up a new window with the address of Google. How would the code be different? (assuming that the script continued after the Google page loaded entirely)

<{POST_SNAPBACK}>

The second one is to simulate after you put in your username and password (before the Send('{ENTER}'))

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I put in two waits because first you wait for the yahoo sign in page to load,

then you fill out the form

and then you change the page title, and submit.

next you wait for the logged in page to load up fully.

With the beta code the form is instantly filled and if you really want to show off, you can do it all hidden, minimised, etc. , or you don't actually have to wait for useless pictures, just for the html to load (form.)

I just put in my generic IEobj function (a lot of borrowedcode, because DaleHohm did a nice job.) It can be done with a lot fewer lines, but this way you can see how to also connect to an exhisting window besides creating a new one.

but actually it should be in this order:

Run('C:\Program Files\Internet Explorer\iexplore.exe "http://mail.yahoo.com"')
winwait("Yahoo","Done")
WinSetTitle("Yahoo", "", "Waiting for page")
; enter your name and pass.
Send("{ENTER}")
winwait("Yahoo","Done"); set to the title that should come up.
; rest of code
Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

cool, thanks for your help guys

Share this post


Link to post
Share on other sites

on a side note:

JSThePatriot

$var = RegRead("HKEY_CLASSES_ROOT\Applications\AutoIt3.exe\shell\Open\Command", "")
$path=stringleft($var,Stringinstr($var,"\",0,-1))
msgbox(1,"copy",$path & "beta\*.* " & $path)

:(


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

LOL Nice. It isnt an issue, but just would be nice. It would save me from doing that or just cutting and pasting over everytime :(

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Yea, I got a script to copy over all my icons and other includes that get written over with a similar script.


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

...you don't actually have to wait for useless pictures, just for the html to load (form.)...

<{POST_SNAPBACK}>

The methods available in the beta version are probably better/faster... but the code below is just part of what I use and it does not wait for the entire page to load:
;
; code to start IE and go to the yahoo
;
While 1
   Send("{TAB}")
   If WinExists("Microsoft Internet Explorer", "ssl_lib") Then
      Send("+{TAB 4}")
      ExitLoop
   EndIf
   Sleep(50)
WEnd

WinWait("Microsoft Internet Explorer", "")
WinActivate("Microsoft Internet Explorer", "")
WinWaitActive("Microsoft Internet Explorer", "")
Send($account)
Sleep(20)
Send("{TAB}")
Sleep(20)
Send($passwd)
Sleep(20)
Send("{ENTER}")

However, if yahoo changes that form, you might have to adjust the code.

logikal16,

Did you get your "Google" question answered? I'm not sure that I understand what you wanted. You asked, "And also, hypothetically... let's say that if you enter the Yahoo login correctly, It opens up a new window with the address of Google. How would the code be different? (assuming that the script continued after the Google page loaded entirely)"

edited: typo

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

yeah i got it figured out... sorry it was kind of badly phrased :-\

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