|
楼主 |
发表于 2009-5-31 11:27:54
|
显示全部楼层
小菜继续补充下,这个问题已经解决.
我写这段是为了弹出窗口输入验证码.
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <INet.au3>
#include <array.au3>
#include <Date.au3>
#AutoIt3Wrapper_run_debug_mode=Y
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("每日自动刷新", 840, 631, 189, 117)
$oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 16, 16, 809, 500)
$Button2 = GUICtrlCreateButton("刷新", 672, 568, 145, 49, $WS_GROUP)
$Edit = GUICtrlCreateEdit("", 32, 560, 601, 65)
GUICtrlSetData(-1, "欢迎回来")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Dim $dbname = "D:\database.mdb"
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
ecplaza()
EndSwitch
WEnd
Func ecplaza()
$conn = ObjCreate("ADODB.Connection")
$rs = ObjCreate("ADODB.Recordset")
$conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $dbname & ";Jet Oledb:Database ")
$rs.ActiveConnection = $conn
$rs.Open("Select * From allcustomer where website = 'ecplaza'")
while Not $rs.eof And Not $rs.bof
$oIE.navigate("http://member.ecplaza.net/auth.do")
_IELoadWait($oIE)
$temps = _IEDocReadHTML($oIE)
$nOffset = 1
While 1
$array = StringRegExp($temps, "value=(.{0,60})name=ConfirmCD", 1, $nOffset)
If @error = 0 Then
$nOffset = @extended
Else
ExitLoop
EndIf
$img = $array[0]
$timg = FileOpen("img.txt", 2)
FileWrite($timg, $img)
FileClose($timg)
WEnd
$p = 1
pngform()
$UserName = _IEGetObjById($oIE, "MemberID")
If IsObj($UserName) Then $UserName.value = $rs.Fields(1).value
$PassWord = _IEGetObjById($oIE, "Password")
If IsObj($PassWord) Then $PassWord.value = $rs.Fields(2).value
$ctest = FileOpen("code.txt", 0)
$contest = FileRead($ctest)
$ConfirmText = _IEGetObjById($oIE, "ConfirmText")
If IsObj($ConfirmText) Then $ConfirmText.value = $contest
FileClose($ctest)
_IEFormImageClick($oIE, "http://image.ecplaza.net/global/tonta/images/gMember/but_login.gif", "src")
_IELoadWait($oIE)
$oIE.navigate("http://member.ecplaza.net/selloffer.do")
_IELoadWait($oIE)
$tempp = _IEDocReadHTML($oIE)
If StringInStr($tempp, "javascript:GoPage(2)") Then
$p = 2
If StringInStr($tempp, "javascript:GoPage(3)") Then
$p = 3
If StringInStr($tempp, "javascript:GoPage(4)") Then
$p = 4
If StringInStr($tempp, "javascript:GoPage(5)") Then
$p = 5
EndIf
EndIf
EndIf
EndIf
$months = @MON
$days = @MDAY
$ds = 12 - $months
$df = 12 - $ds
If StringInStr($tempp, "" & $df & "/" & $days) Then
_IELinkClickByText($oIE, "Logout")
_IELoadWait($oIE)
Sleep(5000)
$rs.movenext
Else
_IELinkClickByText($oIE, "Select All")
_IELoadWait($oIE)
_IELoadWait($oIE)
_IENavigate($oIE, "javascript:DoRepost();")
Send("{enter}")
_IELoadWait($oIE)
For $s = 1 To $p
If $s > 1 Then
_IENavigate($oIE, "javascript:GoPage(" & $s & ");")
_IELinkClickByText($oIE, "Select All")
_IELoadWait($oIE)
_IELoadWait($oIE)
_IENavigate($oIE, "javascript:DoRepost();")
Send("{enter}")
_IELoadWait($oIE)
EndIf
Next
_IELinkClickByText($oIE, "Logout")
_IELoadWait($oIE)
Sleep(5000)
$rs.movenext
EndIf
WEnd
$rs.close
$conn.Close
EndFunc ;==>ecplaza
Func pngform()
$Form2 = GUICreate("加载网页中的验证码演示:", 280, 180)
$Label1 = GUICtrlCreateLabel("验证码:", 8, 43, 70, 17)
GUICtrlSetFont(-1, 12, 400, 0, "黑体")
GUICtrlSetColor(-1, 0xFF0000)
$Input1 = GUICtrlCreateInput("", 90, 90, 113, 35)
$Button8 = GUICtrlCreateButton("确定", 110, 128, 75, 35, $WS_GROUP)
$oIE_code = _IECreateEmbedded()
$GUIActiveX = GUICtrlCreateObj($oIE_code, 70, 24, 150, 50)
_IENavigate($oIE_code, "about:blank", 1)
$oBody = _IETagNameGetCollection($oIE_code, "body", 0)
_IEDocInsertHTML($oBody, 'IE加载中...', "afterbegin")
GUISetState(@SW_SHOW)
_IEAction($oIE_code, "refresh")
$oBody = _IETagNameGetCollection($oIE_code, "body", 0)
$cimg = FileOpen("img.txt", 0)
$contest = FileRead($cimg)
_IEDocInsertHTML($oBody, '<img src="http://member.ecplaza.net/auth.do?cmd=confirmImage&ConfirmCD=' & $contest & '">', "afterbegin")
FileClose($cimg)
While 1
$pMsg = GUIGetMsg()
Switch $pMsg
Case $GUI_EVENT_CLOSE
GUIDelete($Form2)
ExitLoop
Case $Button8
$code = GUICtrlRead($Input1)
$test = FileOpen("code.txt", 2)
FileWrite($test, $code)
FileClose($test)
GUIDelete($Form2)
ExitLoop
EndSwitch
WEnd
EndFunc ;==>pngform
这是这段代码, |
|