Question Open link in opened tab

Plantjen

New member
Joined
Feb 2, 2010
Messages
2
Programming Experience
Beginner
Hello guys,
I have multiple tabs opened in 'any browser' and one of it is titled 'LAME', how can i make links open(by buttons) in that tab?

I have a simple form with two buttons,

Button one:
VB.NET:
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Process.Start("http://www.google.nl/sub1")
    End Sub

Button two:
VB.NET:
 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Process.Start("http://www.google.nl/sub2")
    End Sub
 
You can access the tab by getting the window handle of the tab the following console app will give you an idea on how to get the handle for the tab you are looking for

VB.NET:
Module Module1
   
    Private Declare Function FindWindowEx Lib "user32" _
    Alias "FindWindowExA" (ByVal parentHandle As IntPtr, _
    ByVal childAfter As IntPtr, _
    ByVal lclassName As String, _
    ByVal windowTitle As String) As IntPtr

    Public Declare Function GetWindowText Lib "user32" _
   Alias "GetWindowTextA" _
  (ByVal hwnd As Long, _
   ByVal lpString As String, _
   ByVal cch As Long) As Long

    Public Declare Function GetClassName Lib "user32" _
   Alias "GetClassNameA" _
  (ByVal hwnd As Long, _
   ByVal lpClassName As String, _
   ByVal nMaxCount As Long) As Long


    Sub Main()
        
        Dim Parent As Long
        Dim LastWindowFound As Long
        Parent = 0 '0 is the desktop, which is parent to top-lev. LastWindowFound = 0 
        Dim hWin As System.IntPtr
        Dim sWindowText As String = String.Empty
        Dim r As Long = 0L
        Dim sClassname As String = String.Empty
        Console.WriteLine("Window Text for Window || Window Class || Window Handle")

        Do
            hWin = FindWindowEx(Parent, LastWindowFound, "IEFrame", vbNullString)
            If hWin <> 0 Then
                'Get the window text and class name
                sWindowText = Space$(255)
                r = GetWindowText(hWin, sWindowText, 255)
                sWindowText = Left(sWindowText, r)

                sClassname = Space$(255)
                r = GetClassName(hWin, sClassname, 255)
                sClassname = Left(sClassname, r)
                Console.WriteLine(sWindowText + vbTab + " || " + sClassname + vbTab + " || " + hWin.ToString)
            End If
            LastWindowFound = hWin
        Loop Until hWin = 0

        Console.ReadKey()

    End Sub

End Module
 
Back
Top