Previously I was using ShellWindows() API for IE to get the window Title and URL for my application Now with new development, Microsoft Edge is new and has many features und
Dim tmp1 As String = "" Dim strME As String = "Microsoft Edge"
Try
Dim conditions As Condition = Condition.TrueCondition
Dim BaseElement As AutomationElement = AutomationElement.RootElement
Dim elementCollection As AutomationElementCollection = BaseElement.FindAll(TreeScope.Children, conditions)
Dim AE As AutomationElement
For Each AE In elementCollection
If AE IsNot Nothing Then
tmp1 = AE.GetCurrentPropertyValue(AutomationElement.NameProperty).ToString
If StrComp(Strings.Right(tmp1, strME.Length), strME, vbTextCompare) = 0 Then
Dim elmUrlBar0 As AutomationElement
elmUrlBar0 = AE.FindFirst(TreeScope.Subtree, New PropertyCondition(AutomationElement.AutomationIdProperty, "addressEditBox"))
If elmUrlBar0 IsNot Nothing Then
Dim patterns0 As AutomationPattern() = elmUrlBar0.GetSupportedPatterns()
If patterns0.Length > 0 Then
Dim val As ValuePattern = DirectCast(elmUrlBar0.GetCurrentPattern(patterns0(0)), ValuePattern)
If Not elmUrlBar0.GetCurrentPropertyValue(AutomationElement.HasKeyboardFocusProperty) Then
Dim pvgc As String = LCase(val.Current.Value).Trim
If pvgc.ToString <> "" Then
urls = pvgc.ToString
MsgBox(urls)
End If
End If
End If
End If
End If
End If
Next
Catch ex As Exception
MsgBox("Function AutomationElementData system error." + vbCr + vbCr + ex.ToString, vbExclamation)
End Try