zoukankan      html  css  js  c++  java
  • vb 点超链接 坐标

    引用:http://blog.csdn.net/lbuskeep/article/details/6206615

    核心代码:

    hwnd是窗体的句柄,这个过程会自动查找第一个webbrowser进行点击,其实这种代码是不方便公开的,现在好多的广告代码都会判断鼠标的位置,sendmessage点击的鼠标坐标都是负数,呵呵,小心点 


    '点击广告(窗体,X,Y) 
    Public Sub adGoClick(ByVal hWnd As Long, cX As Long, cY As Long) 
    Dim RetVal As Long 
    Dim hwndPeer As Long 
    Dim ClassString As String * 256 
    Dim tm As Long 
    '点击位置(坐标) 
    tm = cX + cY * 65536 
    '找到IE句柄 
    Dim tmpHwnd As Long 

    hwndPeer = GetWindow(hWnd, GW_CHILD) 
    Do While hwndPeer 
    RetVal = GetClassName(hwndPeer, ClassString, 256) 
    If RetVal <> 0 Then 
    If Left$(ClassString, InStr(ClassString, Chr$(0)) - 1) = "Shell Embedding" Then 
    tmpHwnd = FindWindowEx(hwndPeer, 0&, "Shell DocObject View", vbNullString) 
    If tmpHwnd <> 0 Then 
    tmpHwnd = FindWindowEx(tmpHwnd, 0&, "Internet Explorer_Server", vbNullString) 
    If tmpHwnd <> 0 Then Exit Do 
    End If 
    End If 
    End If 
    '获得下一个窗口的句柄 
    hwndPeer = GetWindow(hwndPeer, GW_HWNDNEXT) 
    Loop 

    If tmpHwnd = 0 Then Exit Sub 
    '执行点击 
    PostMessage tmpHwnd, WM_LBUTTONDOWN, 0, ByVal (tm) 
    Sleep 200 
    PostMessage tmpHwnd, WM_LBUTTONUP, 0, ByVal (tm) 
    DoEvents 
    End Sub

    2.

    Private Sub Command1_Click()
    For i = 0 To WebBrowser1.Document.All.length - 1
    If UCase(WebBrowser1.Document.All(i).tagname) = "A" Then
    If WebBrowser1.Document.All(i).href = "
    http://news.baidu.com/" Then
    WebBrowser1.Document.All(i).Click
    End If
    End If
    Next
    End Sub

    Private Sub Form_Load()
    WebBrowser1.Navigate "
    http://www.baidu.com"
    End Sub

  • 相关阅读:
    @SpringBootApplication注解的理解
    git详解
    什么是maven?
    redis发布订阅实战
    报文示例
    Cisco的ACI究竟是什么?它和SDN有关系吗?
    IP数据包分析
    ARP数据包分析
    水冷精密空调工作原理
    风冷精密空调工作原理
  • 原文地址:https://www.cnblogs.com/sode/p/2694499.html
Copyright © 2011-2022 走看看