Jump to content
devilspride

_IENavigate with Microsoft Edge

Recommended Posts

Posted (edited)

The following code creates a IE blank window

Local $oIE = _IECreate()

 

But when i use Navigate to the URL, it open the URL in Microsoft Edge instead if IE.

_IENavigate($oIE,$url)

 

What should i do to navigate in IE.

Complete code :

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <IE.au3>


#Region TESTING


    Local $url = 'https://www.youtube.com'
    Local $oIE = _IECreate()
    _IENavigate($oIE,$url)
    
#EndRegion

Console Output

IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147023174, Browser has been deleted prior to operation.)

 

I have searched the forums but did not find such kind of post.

Other posts were describing How to use Edge using Web driver selenium.

 

Edit: I am working in Windows10. Recently many changes have been done by Microsoft to IE and Microsoft Edge. (2020)

Earlier in 2019 this was working fine.

Edited by devilspride

Share this post


Link to post
Share on other sites

First, I highly suggest not using IE and switching to WebDriver. IE is going to be unsupported soon (iirc) and is becoming more difficult to work with (imho).

However, I have had things that will only work in IE for some reason, so I've had to work with it in the past. I get this issue a lot when creating IE. I think I use something like this as a workaround... (replace _IECreate with __IECreate in your code)

; (Requires <IE.au3>)
Func __IECreate($sUrl = "about:blank", $iTryAttach = 0, $iVisible = 1, $iWait = 1, $iTakeFocus = 1)
    
    ; Attempt to call the normal method
    Local $oIE = _IECreate($sUrl, $iTryAttach, $iVisible, $iWait, $iTakeFocus)
    ; If the client disconnected, try to find it again
    If @error = $_IEStatus_ClientDisconnected Then
        ConsoleWrite(" Internal Error: " & @error & " Waiting 2 seconds to try attaching." & @CRLF)
        Sleep(2000)
        ; Try to attach using the URL (You may need to check for ANY instance at this point, as it might not have navigated to the URL before disconnecting)
        $oIE = _IEAttach($sUrl, "url")
        ; If we failed to attach, then return that the client disconnected
        If @error Then Return SetError($_IEStatus_ClientDisconnected, @error, False)
    EndIf
    
    Return $oIE

EndFunc

Also, after you call a function, you should check the @error code to see if the code ran successfully. For example, _IECreate has 6 different errors that can be generated. Check the help file to see more information on each of these.

Finally, when you have an issue like this, try searching the forums a little more... I know it can be frustrating, but I found the answer to this by searching $_IESTATUS_ClientDisconnected and clicking on the first link :)


All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

Share this post


Link to post
Share on other sites

Thank you @seadoggie01
 

This worked. I guess the issue, as you described correctly, was inability to Attach the Object to the handle.

I have successfully created IE object using this but ran into few other problems where I am using IEGetElementbyID and other IEGetObjCollection functions.

 

I think i better rewrite my script using WebDriver since I am in early stages of development, else I would end up making a whole bunch of UDF for IE 🤣

Hopefully WebDriver is not too complicated. I am very new to the whole XPath stuff.

Share this post


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

Finally, when you have an issue like this, try searching the forums a little more... I know it can be frustrating, but I found the answer to this by searching $_IESTATUS_ClientDisconnected and clicking on the first link :)

I am still new to the forums so trying to learn how to search effectively. I will keep this is mind from the next time onwards. 

Thank You :)

Share this post


Link to post
Share on other sites

No problem! And in regards to learning XPath, check out this website (it's how I learned nearly everything I know about XPath). I was very new a few months ago too, but the WebDriver helped me fix nearly all of my issues with automating browsers. Good luck! :D


All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts

Share this post


Link to post
Share on other sites
Posted (edited)

@Danp2 thank you. Very useful tool. I will use that from my next project onwards.

Currently, i have successfully completed my first WebDriver script using AutoIt. I will post the code here if it does not violate the forum rules.

 

It is a script that searches YouTube, for a KEYWORD in the videos, and sends a notification to Discord/PushBullet if any new video is uploaded.

Most likely it does not violate TOS of YouTube because there is this Automated Flow by Microsoft Community

Receive an email notification when a new video matches a search on YouTube - Microsoft Community.

Instead of Email, i wanted notifications on Discord/Pushbullet, so made this script.

Can i go ahead and post it here ?

Edited by devilspride

Share this post


Link to post
Share on other sites

devilspride,

I see no reason why you should not post your script as long as it merely notifies and does nothing more.

M23


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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Posted (edited)

@Melba23 Thank you Sir.

Here is the complete Script attached as a .rar file.

Feel free to comment on improving my coding practices as well. I am newbie in coding. AutoIt is the first language i have started to code.

 

*Edit

Func PushBullet_Upload()

is a redundant function which i am working on for future.

YTNotifier.rar

Edited by devilspride

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Deshanur
      Am trying to automate injecting credential on the login form for all kind of Web application for IE. I know how to identify the form name by viewing the source code and using the method - _IEFormGetObjByName($ie, $form_Name).
      I would like to know how to identify or get the form object for the web app where there is no form name tag for example below, for the is I have used - _IEFormGetCollection($ie, 0) to get the form object.
      My Question is does it work for all kind of application "_IEFormGetCollection($ie, 0)" how to identify Index value? is it always 0? is there any better solution?
      The final solution am looking for is find out form object, get the username, password field and inject credential and submit the form.
      How to find out index value? for the forms which does not have form name field.
      $login_form = _IEFormGetCollection($ie, 0) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}") OR This works fine if the form has form name. $login_form = _IEFormGetObjByName($ie, $form_Name) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}")
    • By Zaoka
      I'm trying to create script that would login on my SAP WEBI "web page" and replace some uploaded excel files. But i'm having problem on even the log in.
      These are user fill elements with Firefox Inspector
      <input type="text" id="_id0:logon:CMS" name="_id0:logon:CMS"> <input type="text" id="_id0:logon:USERNAME" name="_id0:logon:USERNAME"> <input type="password" id="_id0:logon:PASSWORD" name="_id0:logon:PASSWORD"> LogOnButton
      <input type="submit" id="_id0:logon:logonButton" value="Log On" class="logonButtonNoHover logon_button_no_hover" onmouseover="this.className = 'logonButtonHover logon_button_hover';" onmouseout="this.className = 'logonButtonNoHover logon_button_no_hover';">  
       
      My example, I tried _IEGetObjByName and _IEGetObjById but the script only open page but will not even fill out the form
        #include <IE.au3> Call("signIn") Func signIn() Global $oIE = _IECreate("http://192.xxx.xxx.xx:xxx/BOE/BI") Sleep (5000) Local $server = _IEGetObjByName($oIE, "_id0:logon:CMS") Local $username = _IEGetObjByName($oIE, "_id0:logon:USERNAME") Local $password = _IEGetObjByName($oIE, "_id0:logon:PASSWORD") Local $button = _IEGetObjById($oIE, "_id0:logon:logonButton") _IEFormElementSetValue($server, "TestServer:1000") _IEFormElementSetValue($username, "MyUserName") _IEFormElementSetValue($password, "MyPass") ; THIS PART ABOUT BUTTON CLICK I DONT UNDERSTAND AT ALL $sSelector = "body > div:nth-of-type(2) > div > div:nth-of-type(3) > div > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr:nth-of-type(1) > td > div > div:nth-of-type(1) > form > div:nth-of-type(5) > button" $signInUC = $oIE.document.QuerySelector($sSelector) _IEAction($signInUC, "click") EndFunc ;==>signIn  
      I would be very grateful for any help
    • By adityaparakh
      Hello ,

      A website I am trying to login with my credentials.
      And retrieve the cookie into a text file.
      Unable to do so.
      Is it that certain,  Httponly , type - are not allowed to be fetched.

      Then further ,
      I will be checking every 5 minutes if my session is active , else re-login and re-fetch the cookie.
      For the second part , I will probably fetch some table and see if not in appropriate format do Part 1 : Fetch Cookie - again.
      Any better way , tips would be appreciated.
       
      Thanks
       
    • By Jamestay97
      Hello! Thanks you for looking at my post
      **No source code I'm sorry work related can't copy information**
      I've been using autoit for about 1 year. 
      I'm having trouble automating a click on an internet explorer web page and I've tried a lot of examples from help pages and forums already. The object I'm trying to click on isnt always in the same spot so I can't use mouse click or control click, I have tried to use the different get collection options and clickbyname, or index or get object. I'm just struggling. 
      Description of object I'm trying to click -- 
      HTML Code looks like <a ng-click.. "Click Here" it appears it's just a click able object named "click here" that opens a hidden window by running a script inside the web page. I'm not able to grab the information from the window unless it's open so I have to automate this click somehow. 
       
      I understand it's difficult to assist without having something to look at, I apologize for that sincerely and appreciate and assistance and suggestions. 
    • By FUD
      hello 
      please i need help 
      i need to open link in default browser only one windows without duplicate if i try to open the same link 
       
      thanks 
×
×
  • Create New...