Jump to content
Sign in to follow this  
parrishjason

Download & Run File from Microsoft Edge

Recommended Posts

parrishjason

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.

Share this post


Link to post
Share on other sites
Juvigy

There is na IE UDF. Check it out. For example _IECreate and _IENavigate

Share this post


Link to post
Share on other sites
junkew
;~ *** 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)

 

Share this post


Link to post
Share on other sites
junkew

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

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
Sign in to follow this  

  • Similar Content

    • jwhausk
      By jwhausk
      Hi, I would like a script to open Edge and navigate to 2 different pages
      Open Edge tab 1 www.MyHomePage.com,  Tab 2 www.google.com
      Thank you, John
    • whiskas
      By whiskas
      Hi all,
      I just upgraded to windows 10 and am using Edge as my browser now. Updated my scripts, but I can not unhide a minimized Edge window with the script anymore.
      WinSetState ( "titlle","", @SW_MAXIMIZE ) works fine, but not if it is minimized. Tried same with SW_SHOW, doesn't work.
      WinExists("title","") -> returns 1, so it is finding my window.
       
              WinWait($title,$text,$timeout)
              If Not WinActive($title,$text) Then WinActivate($title,$text)
              WinWaitActive($title,$text,$timeout)
      Doesn't work also, so I think I tried all but cant get the window back
      Any help would be appreciated
       
    • KimberlyJillPereira
      By KimberlyJillPereira
      I am a newbie in AutoIt. May I know what is the code used to expand the width and height of excel cells because I want to insert pictures in the cell.I tried AutoFit but that doesnt work as I cant specify for the width and height. Only for column width I could expand by using .ColumnWidth but for the row I am not able to expand the row? How to do?? What is the code used ??Please help me and thank you.
    • KimberlyJillPereira
      By KimberlyJillPereira
      I am a newbie in AutoIt. May I know what is the code used to expand the width and height of excel cells because I want to insert pictures in the cell.I tried AutoFit but that doesnt work as I cant specify for the width and height. Only for column width I could expand by using .ColumnWidth but for the row I am not able to expand the row? How to do?? What is the code used ??Please help me and thank you.
    • BigDaddyO
      By BigDaddyO
      I have been using Auto IT along with the IUIAutomation for the nasty bits to perform automation in the Trizetto Facets application and everything is going well, until I was asked to use some of my scripts to generate Load on the system. 
      In order to do this, I would need to Launch My AutoIT script "which opens the Facets application" multiple times.  Each time it is launched a new Facets App on the same computer will open.
      Couple problems with this that I'm hoping someone will be able to help me out with
      On Launch of Facets, I get the PID from Shellexecute which I can then pass into the IUIA to search the proper window which is great, but the Click and Send functions from IUIA don't actually send directly to the control so It can get flaky when 5+ Facets screens are being controlled at the same time. On Launch of Facets, I use the PID to then get the Windows Hwnd.  When trying to do ControlClick, or Control* I can't seem to find any of the Popup windows such as the Database Select, or Login Creds using the Handle from the Main App and text from the Pop window. ex... ControlClick($MainUIhwnd, "text from popup", "Button1")  Is there some other way to identify popup windows for ControlClick type functions?  
×