Jump to content

Download & Run File from Microsoft Edge


Recommended Posts

Hello all.

I currently have an AutoIT script that uses INetGet to retrieve and run files over a network. However, as it stands the app has currently changed to the point where I must open an actual browser in order to be able to get to the file (at least, this is the easiest way).

 

Right now I have an extremely unreliable and clunky set of Send and Click commands to accomplish this task with sleeps in between everything to the point where I *hope* my file was downloaded before I try to click the "Run" button in microsoft edge. 

 

I've been looking into IUIautomation, but I'm having quite a time understanding how to actually use it properly.

 

I'd think that a script to navigate to a URL, download a file, then click "Run" in the browser would be simple. If I can get any help that'd be highly appreciated.

 

Once I see a sample of how to download the file, the navigation part should be quite trivial to figure out.

Link to comment
Share on other sites

;~ *** Standard code maintainable ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

_UIA_setVar("oP1","Title:=.*Microsoft Edge;controltype:=UIA_WindowControlTypeId;class:=ApplicationFrameWindow") ;Download Microsoft WebDriver - Release 10240 from Official Microsoft Download Center ?- Microsoft Edge
_UIA_setVar("oP2","Title:=Microsoft Edge;controltype:=UIA_WindowControlTypeId;class:=Windows.UI.Core.CoreWindow")   ;Microsoft Edge
_UIA_setVar("oP3","Title:=Melding;controltype:=UIA_ToolBarControlTypeId;class:=NotificationBar")    ;Melding

;~ $oUIElement=_UIA_getObjectByFindAll("Opslaan.mainwindow", "title:=Opslaan;ControlType:=UIA_ButtonControlTypeId", $treescope_subtree)
_UIA_setVar("oUIElement","Title:=Opslaan;controltype:=UIA_ButtonControlTypeId;class:=Button") ;ControlType:=UIA_ButtonControlTypeId;classname:=Button")

;~ Actions split away from logical/technical definition above can come from configfiles

_UIA_Action("oP1","highlight")
_UIA_Action("oP1","setfocus")
_UIA_Action("oP2","highlight")
;~ _UIA_Action("oP2","setfocus")
;~ _UIA_Action("oP3","highlight")
;~ _UIA_Action("oP3","setfocus")

_UIA_action("oUIElement","highlight")
;~_UIA_action("oUIElement","click")

Simplespy gave me above code and with some small tweaks it highlights the download button in edge

example link used https://www.microsoft.com/en-us/download/details.aspx?id=48212

then clicked manually download

and then run script which shows that it click on opslaan (you should write the actual language english or other language text)

 

Link to comment
Share on other sites

and to help a little more the example on how to enter an address in the edge addressbar

Be aware I am on a dutch windows so change in description can be needed

;~ *** Standard code maintainable ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

_UIA_setVar("oP1",".*Microsoft Edge;controltype:=UIA_WindowControlTypeId;class:=ApplicationFrameWindow")    ;Download Microsoft WebDriver - Release 10240 from Official Microsoft Download Center ?- Microsoft Edge
_UIA_setVar("oP2","Title:=Microsoft Edge;controltype:=UIA_WindowControlTypeId;class:=Windows.UI.Core.CoreWindow")   ;Microsoft Edge

;~ $oUIElement=_UIA_getObjectByFindAll("Zoekofvoereenwebadresin.mainwindow", "title:=Zoek of voer een webadres in;ControlType:=UIA_EditControlTypeId", $treescope_subtree)
_UIA_setVar("oUIElement","Title:=Zoek of voer een webadres in;controltype:=UIA_EditControlTypeId;class:=RichEditBox") ;ControlType:=UIA_EditControlTypeId;classname:=RichEditBox")

;~ Actions split away from logical/technical definition above can come from configfiles

_UIA_Action("oP1","highlight")
_UIA_Action("oP1","setfocus")

_UIA_Action("oP2","highlight")
_UIA_Action("oP2","setfocus")

_UIA_action("oUIElement","highlight")
_UIA_action("oUIElement","click")
_UIA_Action("oUIElement","setvalue using keys","https://www.microsoft.com/en-us/download/details.aspx?id=48212")
send("{ENTER}")

The exercise to create the download click I leave to you

hint: use simple spy then you will have 3 scripts that you have to modify and combine

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

×
×
  • Create New...