Jump to content

Help with script loging to websites in 2 tabs of IE


Go to solution Solved by Danp2,

Recommended Posts

Hello all,

i am trying to automate my login to 2 different websites.. the first function works well however i cannot make the other function to work since the IE is not entering username/pas or clicking or accessing anything in the new TAB.. so please help me fix the script to make the new tab enter the login info and signs in just like the first tab!( please note that both function works however only the 1st one is in action)

#include <IE.au3>

Call ("website1")

Func website1()
   Global $oIE = _IECreate ("http://www.website1.com")

 Local $username = _IEGetObjByName ($oIE,"username")
   Local $password = _IEGetObjByName ($oIE,"password")

   _IEFormElementSetValue ($username,"URusername")
   _IEFormElementSetValue ($password,"URpassword")
 $inputs = $oIE.document.getElementsByTagName("input")
For $input In $inputs
$input.click()

   EndFunc
Edited by blackeaglemn
Link to comment
Share on other sites

$oIE continues to point to the original tab even after you create the new one. You will need to _IEAttach to the new tab and use the returned object to interact with it.

On a separate issue, have you tried using _IEFormSubmit instead of looping though each of the input elements?

hello sir,thanks for ur reply sir

i added this line : $oIE = _IEAttach("https://website2.com") just belolw the navigate2("https://website2.com)

but it didnt work and i get this

Warning from function _IEAttach, $_IESTATUS_NoMatch

--> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType

--> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType

--> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType

--> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType

".......eah.au3" (35) : ==> Variable must be of type "Object".:

$inputs = $oIE.document.getElementsByTagName("input")

$inputs = $oIE^ ERROR

>Exit code: 1

----

regarding the IEFormSubmit, i read about it but didnt know how to use it.. so as far as this loop is working i dont mind it... but how to make IEAttach work?

Link to comment
Share on other sites

have you double checked the element names on the website(s), you sure they are named "input"?

yes sir, the code and website of func 2 works well if i switch it with the first function, so i guess as stated before it needs to be attached to the new tab but i am not knowing how to use IEattach to make it work

Link to comment
Share on other sites

somewhere in func2 we need to get a handle on website1 and attach to it

I have code at work, but no access to it now, and I have yard work to do

look up wingethandle for the 2nd function then do the attaching

https://www.autoitscript.com/autoit3/docs/functions/WinGetHandle.htm

 $oIE =_IEAttach(WinGetHandle("website2.com"),"HWnd")

 $oIE =_IEAttach(WinGetHandle("website2.com"),"embedded")

i've tried attaching using the one of the above methods...its getting attached but am getting errors afters attaching seems i cant get object after attaching:

Warning from function _IEAttach, $_IESTATUS_NoMatch

--> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType

--> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType

--> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType

--> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType

"------eah.au3" (39) : ==> Variable must be of type "Object".:

$inputs = $oIE.document.getElementsByTagName("input")

$inputs = $oIE^ ERROR

>Exit code: 1

----

please note am designing it for multiple site logins not only 2, so there might also be other functions added or else i would have managed to make the script run on the same ie tab one after the other... but with several logins it will take time..

thanks

Link to comment
Share on other sites

 

i added this line : $oIE = _IEAttach("https://website2.com") just belolw the navigate2("https://website2.com)

If you read the help file entry for _IEAttach, you will see that the default mode is "title". For your code to work, you would need to pass the 2nd parameter as well:

$oIE = _IEAttach("https://website2.com", "url")
Link to comment
Share on other sites

 

If you read the help file entry for _IEAttach, you will see that the default mode is "title". For your code to work, you would need to pass the 2nd parameter as well:

$oIE = _IEAttach("https://website2.com", "url")

Sir , beleive me i've tried all things in help regarding IEattach , its either impossible to get and set object after attaching to or i should use something that enables the get and set objects ... again this is the error i get.. unless someone goes through it and tries the script on there pc then its my pc or IE v11 fault

IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch

--> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType

--> IE.au3 T3.0-1 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType

--> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType

--> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType

"-----ceah.au3" (38) : ==> Variable must be of type "Object".:

$inputs = $oIE.document.getElementsByTagName("input")

$inputs = $oIE^ ERROR

>Exit code: 1

Link to comment
Share on other sites

  • Moderators

There are tab attach/create functions and examples here '?do=embed' frameborder='0' data-embedContent>>

Also a WinGetBrowserObjArray that returns all the browser objects (new IE's or tabs) based on your criteria.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

thanks for your replies... i did solve the problem and its attached on the next tab but after getting several warning until its been attached look

i added this while loop

While 1
  $oIE = _IEAttach("website2 title")
   If IsObj($oIE) Then ExitLoop
WEND

warning is as follows

........ ..... ..... ..... ....( several warning - IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch)

........ .. ... .. .... .... ..
--> IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch
--> IE.au3 T3.0-1 Warning from function _IEAttach, $_IESTATUS_NoMatch
>Exit code: 0    Time: 17.23

then after its looping for some time until its been attached it exists the loop and since its an object now everything runs correctly

i woudnt mind anything better than this code.. but for now it works perfectly..

thanks again

Link to comment
Share on other sites

  • Moderators

While Danp2's link leads to something I wrote, I have a much better/solid solution provided in the link I provided above.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...