Jump to content

Autologin - Multible tabs!


Focus
 Share

Go to solution Solved by Focus,

Recommended Posts

Hi! im trying to create a script that logs me in automaticly everytime i run it. This works fine when it comes to only 1 site, if i add another it will open in a new window even if i manipulate the parameters for IECreate (it seems to be broken). IEAttach does not work either. I googled this problem as anyone would, and found a code for just opening tabs: 

#include <IE.au3>
Const $navOpenInNewTab = 0x0800

Dim $o_IE = _IECreate('http://www.google.com/')
$o_IE.Navigate2('http://www.yahoo.com/' $navOpenInNewTab)
$o_IE.Navigate2('http://www.autoitscript.com/' $navOpenInNewTab)

 

//

My question is: why wont the previous code work with THIS code?:

//

 

#include <IE.au3>
Const $navOpenInNewTab = 0x0800

Global $oIE = _IECreate('https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=http://mail.google.com/mail/&scc=1&ltmpl=default&ltmplcache=2&emr=1')
Call ("SignInGmail")
$oIE.Navigate2('https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1380715680&rver=6.1.6206.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&lc=1053&id=64855&mkt=sv-se&cbcxt=mai&snsc=1' $navOpenInNewTab)
Call ("SingInHotmail")

Func SignInGmail ()

Local $username = _IEGetObjById ($oIE,"Email")
Local $password = _IEGetObjById ($oIE,"Passwd")
Local $button = _IEGetObjById ($oIE, "signIn")

_IEFormElementSetValue ($username, "my Email")
_IEFormElementSetValue ($password, "My Password")

_IEAction ($button, "click")

EndFunc

Func SingInHotmail ()

Local $username = _IEGetObjByName ($oIE,"login")
Local $password = _IEGetObjByName ($oIE,"passwd")
Local $button = _IEGetObjByName ($oIE, "SI")

_IEFormElementSetValue ($username, "My Email")
_IEFormElementSetValue ($password, "My Password")

_IEAction ($button, "click")

EndFunc

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

Can you please enclose code in AutoIt tags for better readability? Use the blue AutoIt icon in the editor.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hi! im trying to create a script that logs me in automaticly everytime i run it. This works fine when it comes to only 1 site, if i add another it will open in a new window even if i manipulate the parameters for IECreate (it seems to be broken). IEAttach does not work either. I googled this problem as anyone would, and found a code for just opening tabs:

#include <IE.au3>
Const $navOpenInNewTab = 0x0800

Dim $o_IE = _IECreate('http://www.google.com/')
$o_IE.Navigate2('http://www.yahoo.com/' $navOpenInNewTab)
$o_IE.Navigate2('http://www.autoitscript.com/' $navOpenInNewTab)

My question is: why wont the previous code work with THIS code?

#include <IE.au3>
Const $navOpenInNewTab = 0x0800

Global $oIE = _IECreate('https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=http://mail.google.com/mail/&scc=1&ltmpl=default&ltmplcache=2&emr=1')
Call ("SignInGmail")
$oIE.Navigate2('https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1380715680&rver=6.1.6206.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&lc=1053&id=64855&mkt=sv-se&cbcxt=mai&snsc=1' $navOpenInNewTab)
Call ("SingInHotmail")

Func SignInGmail ()

Local $username = _IEGetObjById ($oIE,"Email")
Local $password = _IEGetObjById ($oIE,"Passwd")
Local $button = _IEGetObjById ($oIE, "signIn")

_IEFormElementSetValue ($username, "my Email")
_IEFormElementSetValue ($password, "My Password")

_IEAction ($button, "click")

EndFunc

Func SingInHotmail ()

Local $username = _IEGetObjByName ($oIE,"login")
Local $password = _IEGetObjByName ($oIE,"passwd")
Local $button = _IEGetObjByName ($oIE, "SI")

_IEFormElementSetValue ($username, "My Email")
_IEFormElementSetValue ($password, "My Password")

_IEAction ($button, "click")

EndFunc

It logs in to Google perfectly but just opens a tab for the hotmail page without login in.

Link to comment
Share on other sites

Every _IE* function sets @error and writes to the SciTE output pane in case of an error.

If you run your script by pressing F5 in SciTE which messages do you get?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thank you for the respons Water!

I will get back to you since i cannot run the code right now (im at work (: ) but i dont get any direct "errors", the script runs like it should except it wont login to hotmail - it only opens it in a new tab.

But i will see over  the output pane and paste it as soon as i get home!

Link to comment
Share on other sites

This is the complete message:

>"C:\Programering\AutoIT\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Programering\AutoIT\Autoit Files\AutoFlera tabs.au3" /UserParams    
+>20:48:58 Starting AutoIt3Wrapper v.2.1.2.9    Environment(Language:041D  Keyboard:0000041D  OS:WIN_7/Service Pack 1  CPU:X64 OS:X86)
>Running AU3Check (1.54.22.0)  from:C:\Programering\AutoIT\AutoIt3
+>20:48:58 AU3Check ended.rc:0
>Running:(3.3.8.1):C:\Programering\AutoIT\AutoIt3\autoit3.exe "C:\Programering\AutoIT\Autoit Files\AutoFlera tabs.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
C:\Programering\AutoIT\AutoIt3\Include\IE.au3 (2361) : ==> Object referenced outside a "With" statement.:
If IsObj($o_object.document.GetElementsByName($s_Id).item($i_index)) Then
If IsObj($o_object.document.GetElementsByName($s_Id)^ ERROR
->20:49:02 AutoIt3.exe ended.rc:1
>Exit code: 1    Time: 4.423
Edited by Focus
Link to comment
Share on other sites

To access the elements of a form you need to use the _IEForm* functions. So I would replace

_IEGetObjByName ($oIE,"login")

etc. with the corresponding form functions.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

the login functions is not the problem - it works just fine with _IEGetObjById and _IEGetObjByName

 

To be more clear - This following code automaticly logs in to 2 sites:

#include <IE.au3>



Call ("SignInGmail")
Call ("SingInHotmail")

Func SignInGmail ()

Local $oIE = _IECreate('https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=http://mail.google.com/mail/&scc=1&ltmpl=default&ltmplcache=2&emr=1')

Local $username = _IEGetObjById ($oIE,"Email")
Local $password = _IEGetObjById ($oIE,"Passwd")
Local $button = _IEGetObjById ($oIE, "signIn")

_IEFormElementSetValue ($username, "My Email")
_IEFormElementSetValue ($password, "My Password")

_IEAction ($button, "click")

EndFunc

Func SingInHotmail ()

$oIE = _IECreate ('https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1380715680&rver=6.1.6206.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&lc=1053&id=64855&mkt=sv-se&cbcxt=mai&snsc=1')

Local $username = _IEGetObjByName ($oIE,"login")
Local $password = _IEGetObjByName ($oIE,"passwd")
Local $button = _IEGetObjByName ($oIE, "SI")

_IEFormElementSetValue ($username, "My Email")
_IEFormElementSetValue ($password, "My Password")

_IEAction ($button, "click")

EndFunc

BUT it opens the sites in two diffrent browser windows. i want them to apper in the same window but in diffrent tabs. i have tried to send parameters to IECreate to attach the new window to the current one, but it wont work. How can i achive this?

Edited by Focus
Link to comment
Share on other sites

IIRC there has been a thread on this subject on the forum.

Can't find it at the moment but will post a link as soon as I was successful.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Solution

I Solved the problem. I created an Array and catched the URL after each login. then i used:

#include <IE.au3>
Const $navOpenInNewTab = 0x0800

Dim $o_IE = _IECreate(Array[0])
$o_IE.Navigate2(Array[1])
$o_IE.Navigate2(Array[2])

Feels like a pretty dirty workaround, but its the best sollution i've come up with this faar (:

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...