|
![](https://clubstatic.excelhome.net/image/common/ico_lz.png)
楼主 |
发表于 2012-12-23 19:04
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
cumulonimbus 发表于 2012-10-7 11:42 ![](static/image/common/back.gif)
蓝天老师,在这个网站中http://wenku.baidu.com/topic/kaixueji2012/index.html
有个抽奖,但是我弄了一上 ...
Public 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)
Public Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Public Const MOUSEEVENTF_MOVE = &H1 ' mouse move
Public Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Public Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
Sub 下载时先打开网页_下载时候不用再打开网页()
On Error Resume Next
With CreateObject("Shell.Application")
For Each Chuangkou In .Windows
If LCase(TypeName(Chuangkou.document)) = "htmldocument" Then
If Chuangkou.locationurl = "http://wenku.baidu.com/topic/kaixueji2012/index.html" Then
With Chuangkou
t1 = Timer
Do Until Timer > t1 + 5 '等待
DoEvents
Loop
Set r = .document.getElementById("plateFlash")
Cells(2, "A") = r.getBoundingClientRect().Left '+ r.scrollleft '+ .document.parentwindow.screenleft
Cells(2, "B") = r.getBoundingClientRect().Top '+ r.scrolltop '+ .document.parentwindow.screentop
Cells(2, "C") = r.getBoundingClientRect().Right '+ r.scrollRight '+ .document.parentwindow.screenleft
Cells(2, "D") = r.getBoundingClientRect().bottom '+ r.scrollbottom ' + .document.parentwindow.screentop
xleft = (Cells(2, "A") + Cells(2, "C")) / 2 + .document.parentwindow.screenleft + r.scrollleft
ytop = (Cells(2, "B") + Cells(2, "D")) / 2 + .document.parentwindow.screentop + r.scrolltop - 10
SetCursorPos xleft, ytop '把鼠标定位到(xleft,ytop)。分别是X坐标和Y坐标。这里,是把鼠标定位到验证码图片中心
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, xleft, ytop, 0, 0 '在坐标(xleft,ytop)处,弹出右键菜单
'document.All("send").Click
'.Quit
End With
End If
End If
Next
End With
End Sub |
|