VB模拟点击代码(广告+排名)
VB模拟点击代码(广告+排名)
2010年01月02日
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Sub Command1_Click()
Mouse_click 500, 300
End Sub
Private Sub Command2_Click()
Mouse_click 520, 440
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate "your ad url"
End Sub
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
'webbrowser的newwindow2事件中设置新开窗口的对象为webbrowser2
Set ppDisp = WebBrowser2.Objec
End Sub
Private Sub WebBrowser2_DocumentComplete(ByVal pDisp As Object, URL As Variant)
'当下载完毕时移动到二点连接所在位置
WebBrowser2.Document.parentWindow.scrollBy 20, 144
End Sub
Private Sub Mouse_click(x As Integer, y As Integer)
SetCursorPos x, y '模拟鼠标移动到指定坐标(相对于屏幕)
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 '模拟鼠标左键按下
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 '模拟鼠标左键抬起
End Sub