Jump to content
Fivewin Brasil

Pegar o Captcha sem usar a freeimage.dll


kapiaba

Recommended Posts

Pegar o Captcha sem usar a freeimage.dll

// http://forums.fivetechsupport.com/viewtopic.php?f=6&t=35091
	// mostrar un archivo JPG con IMAGE sin freeimage.dll
	#include "FiveWin.ch"
	MEMVAR cFileCaptcha
	Function Captcha()
	   Local oDlg, oFont
   Local oImage, oSay, oGet, oBtn1, oBtn2
   Local cCode := Space(10)
   Local lExit := .F.
   Local hBmp1 := "c:\fwh1701\Bitmaps\no.bmp"
   Local hBmp2 := "c:\fwh1701\Bitmaps\yes.bmp"
	   cFileCaptcha  := "C:\Download\captcha.jpg"
	   SkinButtons()
	   DownloadImageCaptcha()
  
   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12 BOLD
    
   DEFINE DIALOG oDlg FROM 0, 0 TO 10.5, 40;
          TITLE "CAPTCHA";
          FONT oFont;
          STYLE nOr( WS_POPUP,DS_MODALFRAME,WS_CAPTION,WS_VISIBLE )
	   oDlg:lhelpIcon = .F.
	   @    1,  1 XIMAGE oImage SIZE 60, 18 OF oDlg
   
   @  2.5,  4 SAY oSay PROMPT "Codigo: " SIZE 30, 10
   
   @  3.0,  8 GET oGet VAR cCode SIZE 60, 10
	   @  60, 50 BTNBMP oBtn1 SIZE 70, 16 OF oDlg    ;
             2007                                ;
             PROMPT "F3 = Aceita" RESOURCE hBmp1 ;
             LEFT                                ;
             ACTION ( lExit := .T., oDlg:End() )
	   @  14, 75 BTNBMP oBtn2 SIZE 74, 16 OF oDlg ;
             2007                             ;
             PROMPT "F2 = Refresca Captcha"   ;
             RESOURCE hBmp2                   ;
             LEFT                             ;
             ACTION ( DownloadImageCaptcha(), ;
                      oImage:SetSource( "" ), ;
                      oImage:SetSource( cFileCaptcha ) )
	   oDlg:bKeydown  = {|nKey| KeyDownCaptcha(oBtn1, oBtn2, nKey)}
	   ACTIVATE DIALOG oDlg CENTERED                         ;
            ON INIT ( oImage:SetSource( cFileCaptcha ) ) ;
            VALID( lExit )
        
   DeleteObject( hBmp1 )
   DeleteObject( hBmp2 )
     
Return AllTrim(cCode)
	static Function KeyDownCaptcha( oBtn1, oBtn2, nKey )
    
    if nKey == VK_F2
       Eval(oBtn2:bAction)
    elseif nKey == VK_F3
       Eval(oBtn1:bAction)
    endif   
    
Return Nil
	static Function DownloadImageCaptcha()
	   Local cUrl := "http://contribuyente.seniat.gob.ve/BuscaRif/Captcha.jpg"
  
   URLDOWNLOADTOFILE( 0, cUrl, cFileCaptcha )
 
Return NIL
	DLL FUNCTION URLDOWNLOADTOFILE( pCaller AS LONG,    ;
                                cUrl AS LPSTR,      ;
                                cFileName AS LPSTR, ;
                                nReserved AS DWORD, ;
                                nFnCB AS LONG )     ;
                                AS LONG PASCAL      ;
    FROM "URLDownloadToFileA" LIB "urlmon.dll"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...