Jump to content
Arlen

IE check if already logged

Recommended Posts

Arlen

I'm doing a script to login and check my grades for college and some other useful things. But how can I check if i'm already logged in.

What I have tried is to _IEDocReadHTML and then try to read the string with my username or anything that indicates I am logged. But it never returns the actually real html that I am seeing on my browser. It only returned a logged out html version. Anyway I can find out when I am logged or not. Thanks.

Share this post


Link to post
Share on other sites
Simpel

Hi.

Do you attach to an existing browser window or do you create one new? Maybe you have some code for us? In my experience errors often are inside code.

Regards, Conrad


SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites
Danp2

In the past, I've done this by using _IEFormElementGetObjByName to look for a specific field. If it's there, then I know that I can proceed.

In your case, you could look for the login elements. If they are present, then proceed to login. Otherwise, assume that you are already logged in and skip that step.

Share this post


Link to post
Share on other sites
Arlen
3 hours ago, Simpel said:

Hi.

Do you attach to an existing browser window or do you create one new? Maybe you have some code for us? In my experience errors often are inside code.

Regards, Conrad

I use _IECreate for this. 

Local $Username = GUICtrlRead($User)
    ;MsgBox(0,"", $Username)
    Local $Password = GUICtrlRead($Pass)
    ;MsgBox(0,"", $Password)
    Local $Nickname = GUICtrlRead($Nickname_)
    ;MsgBox(0,"", $Nickname)

Local $oIE = _IECreate("https://procesos.intec.edu.do", 0, 1, 1, 1)

Local $DocRead = _IEDocReadHTML($oIE)
FileWrite("Document.html", $DocRead)

If StringInStr($DocRead, $Nickname) Then
    GUICtrlSetData($Status, "Successful !")
Else
    GUICtrlSetData($Status, "Failed")
EndIf

 

Share this post


Link to post
Share on other sites
Arlen
2 hours ago, Danp2 said:

In the past, I've done this by using _IEFormElementGetObjByName to look for a specific field. If it's there, then I know that I can proceed.

In your case, you could look for the login elements. If they are present, then proceed to login. Otherwise, assume that you are already logged in and skip that step.

I tried   "_IEFormElementGetObjByName" but it still found it even logged.

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

  • Similar Content

    • seryth
      By seryth
      I have a script that opens some Excel books that  are stored in SharePoint .  Without getting to much into detail as its a very long story I have to open Internet Explorer to the SP site in order for all of this crap to work. 
       
      Anyway I have a bit of code in my script that i found via google-fu
      $ieList = ProcessList("iexplore.exe") If IsArray($ieList) Then For $I = 1 To Ubound($ieList) -1 ProcessWaitClose($ieList[$I][1]) Next EndIf Exit Now on Windows 7 this bit works great.  On Windows Server 2012 R2 where this things runs is another story.  I need to be able to force close all instances of Internet explorer that are running as part of my code. 
       
      Any help is appreciated. 
    • Joro
      By Joro
      Hi,
      I'm struggeling with the following:
      In a website I have to fill in several items. For the normal fields I am able to fill in the information by using UDF "_IEGetObjByName".
      But there is also a dropdown menu and I can't figure out how to choose te right information from it. I have searched the helpfile and the forum but I can't figure it out.
      Here's an excerpt  from the html-page of the site where the dropdown-menu is mentioned:
      <div class="col-md-10 padding-5">
       <div class="btn-group m-r">
        <input type="hidden" name="bedrijfId" class="bedrijfId" value="">
                  <button type="button" data-toggle="dropdown" class="btn btn-sm btn-default dropdown-toggle" >
                       <span class="dropdown-label">Choose Company</span>
                       <span class="caret"></span>
                  </button>
                        <ul class="dropdown-menu dropdown-select" >
                             <li  data-value="2" data-field="bedrijfId"><a href="#"><input type="radio" name="drp1" />Company 1</a></li>
                             <li  data-value="38" data-field="bedrijfId"><a href="#"><input type="radio" name="drp1" />Company 2</a></li>
                             <li  data-value="42" data-field="bedrijfId"><a href="#"><input type="radio" name="drp1" />Company 3</a></li>
                        </ul>
          </div>
      </div>
       
      How do I select one of the companies from the dropdown menu?
      Thanks
      Joost
    • rudi
      By rudi
      Hello,
      usually I do Win automations, so I have no skills at all to handle HTML forms :-/
      The script to catch and syntax check  the required information from Excel is done.
      Now I'd like to automate the upload using this form, too:
       
      http://flashcardsdeluxe.com/flashcards/Upload.aspx
      What browser is easiest to do so? (IE, Chrome, FF) The Values $DeckCode, $DeckName, $DeckDefinition shall go to their HTML form fields finally "click" the button "upload flashcards" <table width="70%" class="cssCenter" border="0"> <tr> <td style="width: 1%">Deck&nbsp;Code</td> <td style="width: 100%"><input name="ctlDeckCode" type="text" id="ctlDeckCode" style="width:50%;" /> (no spaces allowed)</td> <td></td> </tr> <tr> <td style="width: 1%">Deck&nbsp;Name</td> <td style="width: 100%"><input name="ctlDeckName" type="text" id="ctlDeckName" style="width:50%;" /> (optional)</td> <td style="width: 1%" align="right"><input type="submit" name="ctlUpload" value="Upload Flashcards" id="ctlUpload" /></td> </tr> <tr> <td valign="top" style="padding-top: 5px" >Flashcard&nbsp;Text</td> <td colspan="2"><textarea name="ctlFlashcardText" rows="2" cols="20" id="ctlFlashcardText" style="height:280px;width:100%;"></textarea></td> </tr> </table> If someone kindly could jump in showing how to address just one of the input fields and how to "click" the "upload flashcards" button, I should be able to do the rest myself.
      TIA, Rudi.

    • Pere
      By Pere
      Hi all,
      I've written the script below to automatically login to a website, in this case infusionsoft.com
      The auto login works fine. Is there a way for me to get errors from Internet explorer, if the login fails because of wrong login credentials. I have searched around, but cannot make sense of this.
      Please forgive me if I have overlooked something simple. I am new to autoit. Please see my script below.
      #include <IE.au3>
      #include <MsgBoxConstants.au3>

      Func AccountAutoLogin()
         ;This line sets the website page to open and inject information
         Global $oIE = _IECreate("https://signin.infusionsoft.com/login")
         ;set the variables to pull the username and password object names
         Local $username = _IEGetObjByName ($oIE, "username")
         Local $password = _IEGetObjByName ($oIE, "password")
         ;set the $oButtons variable to pull all the values of the button class
         Local $oButtons = _IETagnameGetCollection($oIE, "button")
         ;set the username and password values on the login form
         _IEFormElementSetValue ($username, "")
         _IEFormElementSetValue ($password, "")
         ; loop through the button class until we find the text on the login button, then click the button
         For $oButton in $oButtons
            If String($oButton.value) = " Log In " Then $test = $oButtons
               _IEAction($oButton, "click")
               _IELoadWait($oIE)
               if (@error) then MsgBox (0, "Error", @error)
            ExitLoop
         Next
      EndFunc
    • kawliga751
      By kawliga751
      I have a workplace GUI that has a search field function that pulls up customer records to allow changes. I am attempting to 1)LOGIN 2)Enter Search field, enter a number and then {ENTER} 3)change specific field once customer record loads. I have very limited experience in GUI manipulation but I am able to login using the below:
      #include <IE.au3> Const $navOpenInNewTab = 0x0800 Dim $oIE = _IECreate('http://asag.xxxxxxx.com/ASAG/index.htm') Call ("RacksheetSignIn") Func RacksheetSignIn () Local $username = _IEGetObjByName ($oIE,"uname") Local $password = _IEGetObjByName ($oIE,"pword") $oIE.Navigate2('http://asag.xxxxxxx.com/apps/RackSheets/LogInSAG/login.asp',2048) _IEFormElementSetValue ($username, "xxxxxxx") _IEFormElementSetValue ($password, "xxxxxxx") Send('{Enter}') EndFunc However I can't seem to use the _IEGetObjByName or Mouseclick to focus on the search field to allow me to enter my search criteria. When I "inspect element" in the Search field I get the attached:
       
      Any help would be MUCH appreciated
       
       
       

×