Quel codice non è corretto ... controlla questo

codice:
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 GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long

Private Const GW_CHILD = 5
Private Const GW_HWNDNEXT = 2
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE

Dim title As String
Dim handle As Long, length As Long

Private Function WindowClass(ByVal hWnd As Long) As String
    Const MAX_LEN As Byte = 255
    Dim strBuff As String, intLen As Integer
    strBuff = String(MAX_LEN, vbNullChar)
    intLen = GetClassName(hWnd, strBuff, MAX_LEN)
    WindowClass = Left(strBuff, intLen)
End Function

Private Function WindowTextGet(ByVal hWnd As Long) As String
    Dim strBuff As String, lngLen As Long
    lngLen = SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0)
    If lngLen > 0 Then
        lngLen = lngLen + 1
        strBuff = String(lngLen, vbNullChar)
        lngLen = SendMessage(hWnd, WM_GETTEXT, lngLen, ByVal strBuff)
        WindowTextGet = Left(strBuff, lngLen)
    End If
End Function

Private Sub Timer1_Timer()
    handle = GetForegroundWindow
    length = GetWindowTextLength(handle)
    title = String(length, Chr$(0))
    GetWindowText handle, title, length + 1
    If InStr(title, "Google Chrome") > 0 Then
        handle = GetWindow(handle, GW_CHILD)
        Do Until handle = 0
            handle = GetWindow(handle, GW_HWNDNEXT)
            If WindowClass(handle) = "Chrome_OmniboxView" Then
                Label1 = WindowTextGet(handle)
                Exit Do
            End If
        Loop
    End If
End Sub