feng8848 2023-02-01 04:07 采纳率: 0%
浏览 8

Visual Basic6.0

Visual Basic6.0如何读取当前 Chrome浏览器网址

  • 写回答

1条回答 默认 最新

  • m0_54204465 2023-02-01 08:12
    关注

    在 Visual Basic 6.0 中读取当前 Chrome 浏览器网址可以使用 Windows API。可以使用 FindWindow 函数找到 Chrome 浏览器的窗口,然后使用 GetWindowText 函数获取标题栏的文本,最后通过 Split 函数从标题栏中提取网址。

    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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
    
    Function GetChromeURL() As String
    Dim hWnd As Long
    Dim sText As String
    Dim aText() As String
    hWnd = FindWindow("Chrome_WidgetWin_1", vbNullString)
    If hWnd Then
        sText = Space$(GetWindowTextLength(hWnd) + 1)
        If GetWindowText(hWnd, sText, Len(sText)) Then
            aText = Split(sText, Chr$(0))
            GetChromeURL = aText(0)
        End If
    End If
    End Function
    

    代码在Windows 系统中适用,在其他系统中不能使用。此外,也不支持所有版本的 Chrome 浏览器,在试用之前确保。

    评论

报告相同问题?

问题事件

  • 创建了问题 2月1日

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100