验证码例子
本帖最后由 lpxx 于 2011-7-4 21:40 编辑验证码例子
附件就不要下载了,费钱,附件源码已经贴出。
#include <GUIConstantsEx.au3>
$iOptOld = Opt("GUIEventOptions", 0)
Opt("GUIEventOptions", $iOptOld)
Global $Char, $t1, $t2, $t3
Global $t5
yzm()
Func yzm()
Local $t4
$t5 = 0
$hWnd = GUICreate("验证码例子", 175, 155, -1, -1, 0x00080000)
$cBg = GUICtrlCreateLabel("", 10, 10, 150, 50)
GUICtrlSetState($cBg, 128)
GUICtrlSetBkColor($cBg, 0x000000)
$cInput = GUICtrlCreateInput("", 10, 70, 150, 20)
$cNew = GUICtrlCreateButton("刷新", 90, 95, 70)
$t4 = yzm_Create()
$cFg = GUICtrlCreateLabel("", 10, 10, 150, 50)
GUICtrlSetBkColor($cFg, -2)
GUISetState()
While 1
Switch GUIGetMsg()
Case -3
Exit
Case $cNew
yzm_Delete()
$t4 = yzm_Create()
GUICtrlSetData($cInput, $t4)
EndSwitch
WEnd
EndFunc ;==>yzm
Func yzm_Create()
Local $sCaptcha = yzm_Generate()
Local $iX = Random(15, 25, 1)
Local $iY = Random(15, 40, 1)
$t3 = "Arial Black"
$t3 = "Comic Sans MS"
$t3 = "Impact"
$t3 = "Tahoma"
$t3 = "System"
$t3 = "Verdama"
$aSplit = StringSplit($sCaptcha, "")
For $x = 0 To 5
$Char[$x] = GUICtrlCreateLabel($aSplit[$x + 1], $iX, $iY)
$iX += 20 + Random(1, 5, 1)
$iY = Random(15, 40, 1)
GUICtrlSetBkColor($Char[$x], -2)
GUICtrlSetColor($Char[$x], Random(0x808080, 0xC0C0C0))
$iNum = Random(1, 7, 1)
Switch $iNum
Case 1
$iStyle = 2 ;2
Case 2
$iStyle = 4 ;4
Case 3
$iStyle = 8 ;8
Case 4
$iStyle = 2 + 4 ;6
Case 5
$iStyle = 4 + 8 ;12
Case 6
$iStyle = 2 + 8 ;10
Case 7
$iStyle = 2 + 4 + 8 ;16
EndSwitch
GUICtrlSetFont($Char[$x], 13, Random(350, 450, 1), $iStyle, $t3)
Sleep(10)
Next
$iX = 15 + Random(1, 10, 1)
$iY = 5 + Random(1, 10, 1)
For $z = 0 To 4
$t1[$z] = GUICtrlCreateLabel("", $iX, $iY, 1, 30)
$iX += 25 + Random(1, 10, 1)
$iY = 5 + Random(1, 30, 1)
GUICtrlSetBkColor($t1[$z], Random(0x808080, 0xC0C0C0))
Next
$iX = 5 + Random(1, 25, 1)
$iY = 20 + Random(1, 10, 1)
For $b = 0 To 1
$t2[$b] = GUICtrlCreateLabel("", $iX, $iY, 130, 1)
$iX = 5 + Random(1, 10, 1)
$iY += 10 + Random(1, 10, 1)
GUICtrlSetBkColor($t2[$b], Random(0x808080, 0xC0C0C0))
Next
Return $sCaptcha
EndFunc ;==>yzm_Create
Func yzm_Delete()
For $y = 0 To 5
GUICtrlDelete($Char[$y])
Next
For $a = 0 To 4
GUICtrlDelete($t1[$a])
Next
For $c = 0 To 1
GUICtrlDelete($t2[$c])
Next
EndFunc ;==>yzm_Delete
Func yzm_Generate()
Local $sCharacters = StringSplit("BCDFGHJKLMNPQRSTVWXYZ1234567890", "")
Local $sCode = ""
For $i = 1 To 6
$sCode &= $sCharacters, 1)]
Next
Return $sCode
EndFunc ;==>yzm_Generate
顶一个,沙发。今天验证码类真多阿 回复 1# lpxx
呵呵,好东西,生成验证码的好例子。不过并没有涉及到验证码识别的问题,而且,生成的验证码是label格式,很容易通过:
$string=""
For $i=3 To 8
$string&=ControlGetText("验证码例子","","Static"&$i)
Next
MsgBox(0,0,$string)
得到。
验证码是不是应该转成图片格式的,以防止被人轻易识别?要是添加这个功能就完善多了。 不错不错 不错不错学习学习 {:face (332):}识别还是生成? 顶啊,感谢楼主分享 是生成验证码。 说的不是很清楚,希望解释一下. 不是识别的阿 LZ是个好人啊 顶上去看下教程,学习下 强烈支持楼主 免税 还不错。。。 想下载 钱不够
页:
[1]
2