[已解决]求教关于验证码已识别后的输入。。大神请进。。
本帖最后由 zzs162 于 2012-9-11 23:30 编辑首先我要申明我不是伸手党,我搜索了,都没看到获取内嵌IE验证码赋予变量的相关资料。
您们也知道验证码重复下载图片会变的。所以恳请帮帮我这小菜。。。
验证码库已经制作好了,识别也可以。
可是怎么样才能获取内嵌IE中的验证码图片要怎么才能获得并且赋予变量?
已经解决
传送门:http://www.autoitx.com/forum.php?mod=viewthread&tid=33024 _regist_baidu()
Func _regist_baidu()
Local $registbaiduok = 0
Local $winregist= GUICreate("注册百度账号", 400, 350, -1, -1)
Local $oIE = _IECreateEmbedded()
Local $GUIActiveX = GUICtrlCreateObj($oIE, -70, -130, 690, 650);嵌入ie控件
_IENavigate($oIE, "https://passport.baidu.com/v2/?reg&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2F", 1) ;注册链接
GUISetState(@SW_SHOW)
Local $oQuery1 = _IEGetObjById ( $oIE, "pass_reg_email_0")
$oQuery1.value = "a1s2d3f4g5@126.com"
_IEAction ( $oQuery1, "focus" )
Sleep(50)
Local $oQuery2 = _IEGetObjById ( $oIE, "pass_reg_username_0")
$oQuery2.value = "a1s2d3f4g5"
_IEAction ( $oQuery2, "focus" )
Sleep(50)
Local $oQuery5 = _IEGetObjById ( $oIE, "pass_reg_password_0")
$oQuery5.value = "a1s2d3f4g5"
_IEAction ( $oQuery5, "focus" )
Sleep(50)
Local $oQuery6 = _IEGetObjById ( $oIE, "pass_reg_repassword_0")
$oQuery6.value = $password
_IEAction ( $oQuery6, "focus" )
Sleep(50)
Local $verifycode = _get_verifycode_baidu($oIE) ;获取验证码
Local $oQuery3 = _IEGetObjById ( $oIE, "pass_reg_verifycode_0")
$oQuery3.value = $verifycode
_IEAction ( $oQuery3, "focus" )
Sleep(50)
Local $oQuery4 = _IEGetObjById ( $oIE, "pass_reg_submit_0")
_IEAction ( $oQuery4, "focus" )
_IEAction ( $oQuery4, "click" )
_IELoadWait($oIE)
GUIDelete($winregist)
EndFunc
Func _get_verifycode_baidu($oIE)
Local $gettimes = 0
Local $iVerifyPic, $iVerifyPics, $winverify, $pic_verify, $input_verify, $button_verify_ok, $msg, $verifycode
Local $verifyimgfile = @TempDir & "\baiduregistverifyimg.jpg"
Local $verifypicfile = @TempDir & "\baiduregistcontrolpic.jpg"
While 1
If $gettimes > 100 Then
Return 0
Else
$iVerifyPic = _IEImgGetCollection($oIE, 1)
_GDIPlus_Startup()
$iVerifyPics = $oIE.Document.body.createControlRange()
$iVerifyPics.add($iVerifyPic)
$iVerifyPics.Select()
$iVerifyPics.execCommand('Copy')
Sleep(100)
_ClipBoard_Open(0)
$iVerifyPics = _ClipBoard_GetDataEx($CF_BITMAP)
$iVerifyPics = _GDIPlus_BitmapCreateFromHBITMAP($iVerifyPics)
_ClipBoard_Close()
FileDelete($verifyimgfile)
_GDIPlus_ImageSaveToFile($iVerifyPics, $verifyimgfile)
If FileGetSize($verifyimgfile) <> FileGetSize($verifypicfile) Then
FileCopy($verifyimgfile, $verifypicfile, 9)
$winverify = GUICreate("验证码-百度", 133, 88, -1, -1,-1,-1)
$pic_verify = GUICtrlCreatePic("", 0, 0, 130, 53, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetImage($pic_verify, $verifypicfile)
$input_verify = GUICtrlCreateInput("", 2, 56, 68, 28,$ES_CENTER)
$button_verify_ok = GUICtrlCreateButton("确定", 72, 56, 57, 29)
GUISetState(@SW_SHOW)
Opt("GUIOnEventMode", 0)
While 1
If StringLen(GUICtrlRead($input_verify)) == 4 Then ExitLoop
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then
ExitLoop
ElseIf $msg = $button_verify_ok Then
ExitLoop
EndIf
WEnd
Opt("GUIOnEventMode", 1)
$verifycode = GUICtrlRead($input_verify)
GUIDelete ( $winverify )
Return $verifycode
Else
Sleep(100)
$gettimes += 1
EndIf
EndIf
WEnd
EndFunc ;==>_get_verifycode_baidu以上是注册百度帐号的例子,代码不完整,仅供参考。可以从中看到验证码图片获取方法及验证码输入方法。 谢谢了。大神。。 有没简单一点的例子呢,看上面看的云里雾里的。。 传送门
http://www.autoitx.com/forum.php?mod=redirect&goto=findpost&pid=371328&ptid=29060 传送门
wua0550 发表于 2012-9-11 00:44 http://www.autoitx.com/images/common/back.gif
首先谢谢5楼您的帮忙
不过您传送门对应的代码会出错"F:\????\AU3????\7.au3" (8) : ==> ???????????("Object").:
$oPic.Add($oImg)
$oPic^ ERROR 出错是你的代码的理解有问题吧
$oie = _IECreate("http://mms.shm.com.cn/smsRegs/2011jc/ListInfo.aspx")
$oImg = _IEImgGetCollection($oie,72)
$oPic = $oie.Document.body.createControlRange()
这三句是必需的~~~$oie就不解释了~~~$oimg中的72指的是图片在网页里的序号,如果网页里没有第72张图那么后面的代码将出现错误~~~所以在定72前~~你要先确定网页中存在多少张图片 出错是你的代码的理解有问题吧
$oie = _IECreate("http://mms.shm.com.cn/smsRegs/2011jc/ListInfo.aspx") ...
wua0550 发表于 2012-9-11 16:26 http://www.autoitx.com/images/common/back.gif
谢谢wua0550的解答。。
我确实太菜了呵呵。受教了,又让我多懂了个函数。。 呵呵呵,用上了
页:
[1]