VB.Net firefox URL in den Zwischenspeicher
Hallo, ich habe gelesen das die Adressenleiste von Firefox kein Handle hat, und wollte es mit SendKeys versuchen die URL in den Zwischenspeicher zu kopieren.
Das Fenster wird zwar gefunden und ist dann im Vordergrund aber bei SendKeys Anweisung wird das Firefoxfenster inaktiviert.
Gibt es eine Möglichkeit an die URL zu kommen?
Gruß waldgnarf
Das Fenster wird zwar gefunden und ist dann im Vordergrund aber bei SendKeys Anweisung wird das Firefoxfenster inaktiviert.
Imports System.Threading
Public Class COPIER
Dim MOZILL As String = "- Mozilla Firefox"
Public Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As Int32) As Int32
Public Declare Function IsWindowVisible Lib "user32.dll" (ByVal hwnd As IntPtr) As Boolean
Public Delegate Function EnumWindowsProc(ByVal hwnd As IntPtr, ByVal lParam As Int32) As Boolean
Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As Int32) As Int32
Public Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As IntPtr) As Int32
Public Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Int32) As Int32
Public Declare Function GetParent Lib "user32.dll" (ByVal intptr As IntPtr) As IntPtr
Public Const GWL_HWNDPARENT As Int32 = -8
Private NEWILI As List(Of String)
Public Declare Function GetConsoleTitle Lib "kernel32" Alias "GetConsoleTitleA" (ByVal lpConsoleTitle As String, ByVal nSize As Integer) As Integer
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer
Declare Auto Function FindWindow Lib "USER32.DLL" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Declare Auto Function SetForegroundWindow Lib "USER32.DLL" (ByVal hWnd As IntPtr) As Boolean
Private Sub COPIER_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Minimized
NEWILI = New List(Of String)
EnumWindows(AddressOf ENVIPR, CInt(True))
For Each FENSTE As String In NEWILI
If InStr(FENSTE, MOZILL) > 0 Then
MOZILL = FENSTE
Exit For
End If
Next
ShowWindow(FindWindow(vbNullString, MOZILL), 1)
SetForegroundWindow(FindWindow(vbNullString, MOZILL))
Thread.Sleep(900)
SendKeys.Send("^L")
SendKeys.Send("^C")
End Sub
Private Function ENVIPR(ByVal hwnd As IntPtr, ByVal lParam As Int32) As Boolean
If GetParent(hwnd) = IntPtr.Zero Then
If GetWindowLong(hwnd, GWL_HWNDPARENT) = 0 Then
Dim str As String = String.Empty.PadLeft(GetWindowTextLength(hwnd) + 1)
GetWindowText(hwnd, str, str.Length)
If Not String.IsNullOrEmpty(str.Substring(0, str.Length - 1)) Then NEWILI.Add(str.Substring(0, str.Length - 1))
End If
End If
ENVIPR = True
End Function
End Class
Gibt es eine Möglichkeit an die URL zu kommen?
Gruß waldgnarf
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-ID: 130433
Url: https://administrator.de/forum/vb-net-firefox-url-in-den-zwischenspeicher-130433.html
Ausgedruckt am: 23.12.2024 um 14:12 Uhr
3 Kommentare
Neuester Kommentar
Hallo waldgnarf,
das ist zwar VB5/6 aber es gibt dir eventuell einen Hinweis für VB.Net
Gruss und schönen Advent
Tsuki
das ist zwar VB5/6 aber es gibt dir eventuell einen Hinweis für VB.Net
Gruss und schönen Advent
Tsuki