shano 发表于 2010-10-29 20:04:36

加载验证码到GUI

本帖最后由 shano 于 2010-10-29 21:42 编辑

在论坛找了些例子但是换成我的URL就无法显示请童鞋帮我看看
http://www.ipal.com/?_task=index&_action=vcode;我想加载的图片 无法显示
http://gd.ct10000.com/loginCode;例子的图片 可以正常显示
C:\Documents and Settings\Administrator\Local Settings\Temp   路径下可以下载到正确的图片 就是无法加载到GUI上
----------------------------------------------------------------------------------------------------------------------------------
刚截了下包原来验证码是PNG格式的 所以用GUICtrlCreatePic 就无法显示
有加载PNG的命令吗





#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
$size = FileGetSize (@ScriptFullPath)
Global $url = "http://www.ipal.com/?_task=index&_action=vcode";直接获得验证码的url
;Global $url = "http://gd.ct10000.com/loginCode";直接获得验证码的url
Global $jpg = @TempDir&'\tem'&$size&'.jpg';临时储存的文件
download();下载一个图片
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("下载验证码", 354, 143, 292, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Pic1 = GUICtrlCreatePic($jpg, 60, 18, 228, 70, BitOR($GUI_SS_DEFAULT_PIC,$WS_CLIPSIBLINGS))
GUICtrlCreateLabel("图像:", 2, 44, 40, 17)
$Button1 = GUICtrlCreateButton("换", 248, 66, 56, 46, $BS_DEFPUSHBUTTON);$BS_DEFPUSHBUTTON=回车时相当于按了这个按钮
GUICtrlSetOnEvent($Button1, "Button1Click")
GUICtrlCreateLabel("识别:", 10, 77, 40, 17)
$Input1 = GUICtrlCreateInput("", 87, 83, 41, 21,$ES_NUMBER);本例子只可输入数字,当然要根据你的验证码进行设定
ControlFocus ($Form1, "",$Input1);输入焦点
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
      Sleep(100)
WEnd
Func Button1Click()
        $in = GUICtrlRead ($Input1)
        if StringLen ( $in ) = 0 Then
                GUICtrlSetData ($Input1,"" )
                download()
      GUICtrlSetImage ($Pic1,$jpg)
        Elseif StringLen ( $in ) <> 4 And StringLen ( $in ) > 0 Then
                GUICtrlSetData ($Input1,"" )               
        Else               
      baocun()
                download()
      GUICtrlSetImage ($Pic1,$jpg)
        EndIf                             
EndFunc
Func Form1Close()
      GUISetState(@SW_HIDE,$Form1)      
Exit
EndFunc
Func download()
      InetGet ($url,$jpg)
                Sleep(5000)
EndFunc
Func baocun();保存验证码图片为你输入的文件名
       FileCopy($jpg,@ScriptDir&"\验证码\"&GUICtrlRead ($Input1)&".jpg",9)
           GUICtrlSetData ($Input1,"" )
EndFunc

shano 发表于 2010-10-29 22:18:43

顺便问一嘴我想识别这样的图片有戏没

xyyie 发表于 2010-10-30 09:02:43

这个很难哦。

qhxnhuang 发表于 2010-10-30 09:11:00

不是很懂你的意思
页: [1]
查看完整版本: 加载验证码到GUI