Sign in to follow this  
Followers 0
parrishjason

Download & Run File from Microsoft Edge

4 posts in this topic

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



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

Share this post


Link to post
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)

 

Share this post


Link to post
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

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  
Followers 0

  • Similar Content

    • Rhazz
      I can't activate the "File Open" window on Chrome and Edge
      By Rhazz
      Hi, I'm trying to upload a file with a web browser but I can't select the Open File window to select the file that I want to upload.
      TL;DR I can't handle the Open File window of Chrome and MS Edge. AutoIt just doesn't find it by its title (in Firefox yes, but not on Chrome and MS Edge).
      With another software (Selenium Webdriver in Python) I access to a web page with a common HTML5 file uploader and I click on it, but when the Open File window comes up, I want to select a file and press Enter (write the filepath that I give and press Enter key or Open button).
      I have the idea, and I have the script on AutoIt too... but it doesn't work on Windows Edge and Chrome, only works on Firefox and Pale Moon (who are basically the same).
      Here is my code:
      #include <MsgBoxConstants.au3> $title = "Abrir" ; My Windows is in spanish, but I guess it's "Open" in English and it's the same code WinActivate($title) If WinActive($title) Then send("C:\Users\myuser\images\my_image.jpg") Send("{ENTER}") Else MsgBox($MB_SYSTEMMODAL, "WinActive", "Window not found.") EndIf In Firefox (and Pale Moon) the Open File window comes up, the file path is written and the Enter key is pressed. It works perfect.
      In Chrome and Edge, I never see the Open File window on top... and I neither see "Window not found" message (seems like AutoIt finds it but doesn't send keys).
      Edit: before to send this post, I started thinking again and... after several tests, I discovered one thing: when you select the window, in Firefox (and Pale Moon) the cursor goes to the combobox (where I have to put the text) and it's possible to write just after clicking (or opening, what in AutoIt it is "Activate" I guess) the window but in Chrome and Edge it isn't like that, when you click the window, the cursor doesn't go to the combobox.
      With that "discovery", I tried to select the combobox but... I failed again. And now I have no idea how to go ahead.
      #include <MsgBoxConstants.au3> $title = "Abrir" WinActivate($title) If WinActive($title) Then ControlClick($title, "", 1148) ; Still it does not work send("C:\Users\myuser\images\my_image.jpg") Send("{ENTER}") Else MsgBox($MB_SYSTEMMODAL, "WinActive", "Window not found.") EndIf  
    • Mian
      How to select or delete a column in excel sheet on the basis of heading in the first row
      By Mian
      I wrote a script which deletes a single or range of columns from an excel file, however, I found that the file is frequently modified and the automation is not smooth.
      The task can be achieved in two ways, please help me in whichever is simple.
      1) Instead of column number, I delete single column or range of columns on the basis of heading in the first cell of the column. This way I will be able to select the desired columns even if the column number changes.
      2) I select the columns on the basis of heading in the first cell of each column and paste it in a new sheet or new excel file. This way I will get the desired column where ever they are in the file.
      Thanks
       
    • Kyan
      Selectable label
      By Kyan
      I know this ain't much (nothing for autoit experts) but can help someone who was looking for a selectable label
       
      (I used the hex values to avoid #include <EditConstants.au3>, the vars are in comment in front of the 2nd line)
       
      $Form1 = GUICreate("Test", 351, 50) $Label1 = GUICtrlCreateEdit("Selectable Label", 10, 4, 176, 20, 0x0800,0x00000020) ;$ES_READONLY, $WS_EX_TRANSPARENT GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 Exit EndSwitch WEnd PS: I think the same could be accomplished with GUICtrlCreateInput()
    • ngskicker
      Set text on a control using IUIAutomation.
      By ngskicker
      I don't know if this is a correct place to ask this, so forgive me if this is the wrong place.
      I need to set text in a text field, and then press enter, this is a text field on "Microsoft Access Database Project", this control is not visible on AutoItInfo, below is what I get from simplespy
      Mouse position is retrieved 433-228 At least we have an element [20.40.22][OKttbx] Having the following values for all properties: Title is: <20.40.22> Class := <OKttbx> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 366;221;151;15 *** Parent Information top down *** 4: Title is: <Desktop> Class := <#32769> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 0;0;1366;768 "Title:=Desktop;controltype:=UIA_PaneControlTypeId;class:=#32769" 3: Title is: <Registrasi Px RSMLA> Class := <OMain> controltype:= <UIA_WindowControlTypeId> ,<50032> , (0000C370) -8;-8;1382;744 "Title:=Registrasi Px RSMLA;controltype:=UIA_WindowControlTypeId;class:=OMain" 2: Title is: <Workspace> Class := <MDIClient> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 0;74;1366;654 "Title:=Workspace;controltype:=UIA_PaneControlTypeId;class:=MDIClient" 1: Title is: <Appointment Form> Class := <OForm> controltype:= <UIA_WindowControlTypeId> ,<50032> , (0000C370) 259;124;847;537 "Title:=Appointment Form;controltype:=UIA_WindowControlTypeId;class:=OForm" 0: Title is: <> Class := <OFormSub> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 262;197;824;343 "Title:=;controltype:=UIA_PaneControlTypeId;class:=OFormSub" ;~ *** Standard code *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP3=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Registrasi Px RSMLA;controltype:=UIA_WindowControlTypeId;class:=OMain", $treescope_children) _UIA_Action($oP3,"setfocus") Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=Workspace;controltype:=UIA_PaneControlTypeId;class:=MDIClient", $treescope_children) _UIA_Action($oP2,"setfocus") Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=Appointment Form;controltype:=UIA_WindowControlTypeId;class:=OForm", $treescope_children) _UIA_Action($oP1,"setfocus") Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=OFormSub", $treescope_children) _UIA_Action($oP0,"setfocus") _UIA_setVar("20.40.22.mainwindow","title:=20.40.22;classname:=OKttbx") _UIA_action("20.40.22.mainwindow","setfocus") *** Detailed properties of the highlighted element *** UIA_title:= <20.40.22> UIA_text:= <20.40.22> UIA_regexptitle:= <20.40.22> UIA_class:= <OKttbx> UIA_regexpclass:= <OKttbx> UIA_iaccessiblechildId:= <0> UIA_handle:= <1311620> UIA_RuntimeId:= <42;1311620> UIA_BoundingRectangle:= <366;221;151;15> UIA_ProcessId:= <1404> UIA_ControlType:= <50033> UIA_LocalizedControlType:= <pane> UIA_Name:= <20.40.22> UIA_HasKeyboardFocus:= <True> UIA_IsKeyboardFocusable:= <True> UIA_IsEnabled:= <True> UIA_ClassName:= <OKttbx> UIA_Culture:= <0> UIA_IsControlElement:= <True> UIA_IsContentElement:= <True> UIA_IsPassword:= <False> UIA_NativeWindowHandle:= <1311620> UIA_IsOffscreen:= <False> UIA_Orientation:= <0> UIA_FrameworkId:= <Win32> UIA_IsRequiredForForm:= <False> UIA_IsDockPatternAvailable:= <False> UIA_IsExpandCollapsePatternAvailable:= <False> UIA_IsGridItemPatternAvailable:= <False> UIA_IsGridPatternAvailable:= <False> UIA_IsInvokePatternAvailable:= <False> UIA_IsMultipleViewPatternAvailable:= <False> UIA_IsRangeValuePatternAvailable:= <False> UIA_IsScrollPatternAvailable:= <False> UIA_IsScrollItemPatternAvailable:= <False> UIA_IsSelectionItemPatternAvailable:= <False> UIA_IsSelectionPatternAvailable:= <False> UIA_IsTablePatternAvailable:= <False> UIA_IsTableItemPatternAvailable:= <False> UIA_IsTextPatternAvailable:= <False> UIA_IsTogglePatternAvailable:= <False> UIA_IsTransformPatternAvailable:= <False> UIA_IsValuePatternAvailable:= <False> UIA_IsWindowPatternAvailable:= <False> UIA_ValueIsReadOnly:= <True> UIA_RangeValueValue:= <0> UIA_RangeValueIsReadOnly:= <True> UIA_RangeValueMinimum:= <0> UIA_RangeValueMaximum:= <0> UIA_RangeValueLargeChange:= <0> UIA_RangeValueSmallChange:= <0> UIA_ScrollHorizontalScrollPercent:= <0> UIA_ScrollHorizontalViewSize:= <100> UIA_ScrollVerticalScrollPercent:= <0> UIA_ScrollVerticalViewSize:= <100> UIA_ScrollHorizontallyScrollable:= <False> UIA_ScrollVerticallyScrollable:= <False> UIA_SelectionCanSelectMultiple:= <False> UIA_SelectionIsSelectionRequired:= <False> UIA_GridRowCount:= <0> UIA_GridColumnCount:= <0> UIA_GridItemRow:= <0> UIA_GridItemColumn:= <0> UIA_GridItemRowSpan:= <1> UIA_GridItemColumnSpan:= <1> UIA_DockDockPosition:= <5> UIA_ExpandCollapseExpandCollapseState:= <3> UIA_MultipleViewCurrentView:= <0> UIA_WindowCanMaximize:= <False> UIA_WindowCanMinimize:= <False> UIA_WindowWindowVisualState:= <0> UIA_WindowWindowInteractionState:= <0> UIA_WindowIsModal:= <False> UIA_WindowIsTopmost:= <False> UIA_SelectionItemIsSelected:= <False> UIA_TableRowOrColumnMajor:= <2> UIA_ToggleToggleState:= <2> UIA_TransformCanMove:= <False> UIA_TransformCanResize:= <False> UIA_TransformCanRotate:= <False> UIA_IsLegacyIAccessiblePatternAvailable:= <True> UIA_LegacyIAccessibleChildId:= <0> UIA_LegacyIAccessibleName:= <20.40.22> UIA_LegacyIAccessibleRole:= <10> UIA_LegacyIAccessibleState:= <1048580> UIA_IsDataValidForForm:= <False> UIA_ProviderDescription:= <[pid:5708,hwnd:0x140384 Main:Nested [pid:1404,hwnd:0x140384 Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]> UIA_IsItemContainerPatternAvailable:= <False> UIA_IsVirtualizedItemPatternAvailable:= <False> UIA_IsSynchronizedInputPatternAvailable:= <False>
    • Servant
      Delete the 2nd until the last sentence of a set paragraph range on a Word
      By Servant
      I tried a lot of techniques but still have no luck..
      How can I delete the second sentence until the last sentence of a set paragraph range on a Microsoft Word document?
      #include <Word.au3> Global $oWord, $oDoc $oWord = _Word_Create() $oDoc = _Word_DocGet($oWord, 1) Global Const $Count = $oDoc.Paragraphs.Count For $i = 0 To $Count - 1    $oRange = _Word_DocRangeSet($oDoc, -1, $wdParagraph, $i, $wdParagraph, 1)    ; Here will be placed the missing code Next Sample of the beginning of a Word document:
      This is a sentence 1. This is a sentence 2. This is a sentence 3. This is a sentence 4. This is a sentence 5. This is a sentence 6. This is a sentence 7. This is a sentence 8. This is a sentence 9. Sample of the final result:
      This is a sentence 1. This is a sentence 4. This is a sentence 7.