05-02-19, 01:03 AM
(11-09-18, 02:08 AM)bidaya كتب : صلىي علي النبي محمد
للافادة اخواني كود جلب الرابط بالمتصفح
لحد الان توصلت الى متصفحين
قوقل كروم و المتصفح العجوز
كود الفير فوكس لم ينجح معي
ان شاء الله لما ينجح رابح احطه على طول
كود :
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Diagnostics
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports NDde.Client
Imports System.Windows.Automation
Imports SHDocVw
Public Class Form5
Public Function GetIExploreActiveTabUrl() As String
Dim processesByName = Process.GetProcessesByName("iexplore")
If processesByName.Length <> 0 Then
Dim oDde = New DdeClient("IExplore", "www_GetWindowInfo")
oDde.Connect()
Dim url = oDde.Request("1", 5000)
oDde.Disconnect()
If url.Contains(",") Then url = url.Split(","c)(0).Replace("""", "")
Return url
End If
Return Nothing
End Function
Public Function GetChromeActiveTabUrl() As String
Dim procsChrome = Process.GetProcessesByName("chrome")
For Each chrome In procsChrome
If chrome.MainWindowHandle = IntPtr.Zero Then Continue For
Dim elerent = AutomationElement.FromHandle(chrome.MainWindowHandle)
If elerent Is Nothing Then Return Nothing
Dim conditins As Condition = New AndCondition(New PropertyCondition(AutomationElement.ProcessIdProperty, chrome.Id), New PropertyCondition(AutomationElement.IsContentElementProperty, True), New PropertyCondition(AutomationElement.IsContentElementProperty, True), New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit))
Dim elerentx = elerent.FindFirst(TreeScope.Descendants, conditins)
Return (CType(elerentx.GetCurrentPattern(ValuePattern.Pattern), ValuePattern)).Current.Value
Next
Return Nothing
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim url = GetChromeActiveTabUrl()
Dim url1 = GetIExploreActiveTabUrl()
If Not String.IsNullOrEmpty(url) Then TextBox1.Text = url
If Not String.IsNullOrEmpty(url1) Then TextBox1.Text = url1
End Sub
End Class
