none
There is a question about UI automation in Windows 10. RRS feed

  • Question

  • hi, when i use the follow method to save the file, it exists a problem.

    in fact, the file have been download, but the save position is not right, it download by default path , and default name. but not the path which set by the user (fullPath), and it's ok in Window7 and windows2008.

    when run this method, the filename path have been set, and the "save" button have been clicked. but in fact the file was download in a wrong directory.

    thanks for your reply.

     Private Function Handle_SaveAs_Dialog(ByVal fullPath As String) As Boolean
            Dim conditions As AndCondition
            Dim aeDialog As AutomationElement = WaitForDialog()
            If aeDialog Is Nothing Then Return False

            Try
                'get the file name field
                conditions = New AndCondition(New PropertyCondition(AutomationElement.AutomationIdProperty, "1001"), _
                            New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit))
                Dim aeFileName As AutomationElement = aeDialog.FindFirst(TreeScope.Descendants, conditions)
                Dim vpFileName As ValuePattern = aeFileName.GetCurrentPattern(ValuePattern.Pattern)
                vpFileName.SetValue(fullPath)// it set ok, but the result seems not set sucess.
                Sleep(150)

                'get the save button
                conditions = New AndCondition(New PropertyCondition(AutomationElement.AutomationIdProperty, "1"), _
                            New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button))
                Dim aeSaveBtn As AutomationElement = aeDialog.FindFirst(TreeScope.Descendants, conditions)
                Dim ipSaveBtn As InvokePattern = aeSaveBtn.GetCurrentPattern(InvokePattern.Pattern)
                ipSaveBtn.Invoke()
                Sleep(1500)
            Catch ex As Exception
                Return False
            End Try

            Return True
        End Function

    Monday, July 11, 2016 7:53 AM

All replies


  • Hello wexixion,
    The purpose of this forum is to support the Open Specifications documentation. You can read about the Microsoft Open Specifications program from http://www.microsoft.com/openspecifications/en/us/default.aspx . The library of Open Specification documents can be accessed from http://msdn.microsoft.com/en-us/library/dd208104(PROT.10).aspx.

    Your question may be more applicable to the following forum.
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wpf 

    Regards,
    Sreekanth Nadendla
    Microsoft Windows Open Specifications
    Monday, July 11, 2016 3:17 PM
    Moderator