For simplicity of this app that I am making, I am still using VB6.
I have researched some on Google on how to get the URL from the Google Chrome browser but unfortunately it only gives the page title. Below is the code that I got.
Option Explicit
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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
Private Sub Command1_Click()
Dim dhWnd As Long
Dim chWnd As Long
Dim Web_Caption As String * 2560
Dim Web_hWnd As Long
Dim URL As String * 2560
Dim URL_hWnd As Long
dhWnd = GetDesktopWindow
chWnd = FindWindowEx(0, 0, "Chrome_WidgetWin_1", vbNullString)
Web_hWnd = FindWindowEx(dhWnd, chWnd, "Chrome_WidgetWin_1", vbNullString)
URL_hWnd = FindWindowEx(Web_hWnd, 0, "Chrome_OmniboxView", vbNullString)
Call SendMessage(Web_hWnd, WM_GETTEXT, 2560, ByVal Web_Caption)
Call SendMessage(URL_hWnd, WM_GETTEXT, 2560, ByVal URL)
Text1.Text = Split(Web_Caption, Chr(0))(0) & vbCrLf & Split(URL, Chr(0))(0)
End Sub
I have already asked from different forums on how to do this but they have no answer and so I would like to try to ask help here.
I hope somebody can help me get the URL of Google Chrome.