Struttura di un Capthca Plugin
In questa pagina sarà spiegata la struttura dei Captcha Plugins. Attenzione però perchè la spiegazione è valida per le versioni del programma uguali o superiori alla 0.02.
In questa pagina sarà spiegata la struttura dei Captcha Plugins. Attenzione però perchè la spiegazione è valida per le versioni del programma uguali o superiori alla 0.02.
Funzioni di base
Tutti i CP (Captcha plugins) devono avere almeno una funzione statica (condivisa) e pubblica chiamata "getCaptcha" che prenda come argomento un System.Drawing. Image (ricordo che stiamo parlando di un'applicazione .Net) e che restituisca una stringa contenente il valore del captcha. Se scritto in codice dovrebbe essere:
Tutti i CP (Captcha plugins) devono avere almeno una funzione statica (condivisa) e pubblica chiamata "getCaptcha" che prenda come argomento un System.Drawing. Image (ricordo che stiamo parlando di un'applicazione .Net) e che restituisca una stringa contenente il valore del captcha. Se scritto in codice dovrebbe essere:
- C#
public static string getCaptcha(System.Drawing.Image img) { //your code here }
- VB (Visual Basic)
Public Shared Function getCaptcha (ByVal img As System.Drawing. Image) As String 'your code here End Function
Naturalmente ci possono essere anche altre funzioni nel plug-in, ma solo getCaptcha verrà chiamata.
Un esempio (Human captcha catcher)
VB
Imports System.Windows.Forms
Imports System.Drawing
Public Class CHPTDialog
Inherits System.Windows.Forms.Form
Private img As Image
Public Result As String
'Richiesto da Progettazione Windows Form
Private components
As System.ComponentModel.IContainer
'NOTA: Tutto questo è
per la progettazione...
<System.Diagnostics.DebuggerStepThrough()>
_
Private Sub InitializeComponent()
Me.Label1 = New
System.Windows.Forms.Label
Me.resultB = New
System.Windows.Forms.TextBox
Me.GroupBox1 = New
System.Windows.Forms.GroupBox
Me.cButton = New
System.Windows.Forms.Button
Me.okButton = New
System.Windows.Forms.Button
Me.dImage = New
System.Windows.Forms.PictureBox
Me.GroupBox1.SuspendLayout()
CType(Me.dImage, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Bottom) _
Or
System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(198, 15)
Me.Label1.Name = "Label1"
Me.Label1.Size = New
System.Drawing.Size(135, 13)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Inserisci questo codice qui:"
'
'resultB
'
Me.resultB.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Bottom) _
Or
System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.resultB.Location = New
System.Drawing.Point(339, 12)
Me.resultB.Name = "resultB"
Me.resultB.Size = New System.Drawing.Size(90, 20)
Me.resultB.TabIndex = 1
'
'GroupBox1
'
Me.GroupBox1.BackColor = System.Drawing.Color.LightCyan
Me.GroupBox1.Controls.Add(Me.cButton)
Me.GroupBox1.Controls.Add(Me.okButton)
Me.GroupBox1.Controls.Add(Me.dImage)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Controls.Add(Me.resultB)
Me.GroupBox1.Location =
New System.Drawing.Point(0, 0)
Me.GroupBox1.MinimumSize = New
System.Drawing.Size(247, 69)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(435, 69)
Me.GroupBox1.TabIndex = 2
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Decode Captcha"
'
'cButton
'
Me.cButton.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Bottom) _
Or
System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.cButton.Location = New
System.Drawing.Point(267, 38)
Me.cButton.Name = "cButton"
Me.cButton.Size = New System.Drawing.Size(75, 23)
Me.cButton.TabIndex = 4
Me.cButton.Text = "Annulla"
Me.cButton.UseVisualStyleBackColor = True
'
'okButton
'
Me.okButton.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Bottom) _
Or
System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.okButton.Location = New
System.Drawing.Point(348, 38)
Me.okButton.Name = "okButton"
Me.okButton.Size = New System.Drawing.Size(75, 23)
Me.okButton.TabIndex = 3
Me.okButton.Text = "OK"
Me.okButton.UseVisualStyleBackColor = True
'
'dImage
'
Me.dImage.Location = New System.Drawing.Point(12, 19)
Me.dImage.Name = "dImage"
Me.dImage.Size = New
System.Drawing.Size(156, 42)
Me.dImage.TabIndex = 2
Me.dImage.TabStop = False
'
'CHPTDialog
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(465, 93)
Me.Controls.Add(Me.GroupBox1)
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.None
Me.MaximizeBox =
False
Me.MinimizeBox = False
Me.MinimumSize = New
System.Drawing.Size(247, 69)
Me.Name = "CHPTDialog"
Me.ShowInTaskbar = False
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterParent
Me.Text =
"Dialog1"
Me.TransparencyKey =
System.Drawing.SystemColors.Control
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
CType(Me.dImage, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents
Label1 As System.Windows.Forms.Label
Friend WithEvents
resultB As System.Windows.Forms.TextBox
Friend WithEvents
GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents
dImage As System.Windows.Forms.PictureBox
Friend WithEvents
cButton As System.Windows.Forms.Button
Friend WithEvents
okButton As System.Windows.Forms.Button
Protected
Overrides Sub Dispose(ByVal disposing As Boolean)
If
disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
Public Sub
New(ByVal image As Image)
InitializeComponent()
img =
image
Me.Width = img.Width + 40 + (resultB.Location.X -
Label1.Location.X + resultB.Width)
Me.Height = img.Height +
40
dImage.Size = img.Size
dImage.Image = img
GroupBox1.Location = Point.Empty
GroupBox1.Size = Size
End
Sub
Private Sub cancelButton_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles cButton.Click
Result = ""
Me.Close()
End Sub
Private Sub
okButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles okButton.Click
Result =
resultB.Text
Me.Close()
End Sub
End Class
''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''questa è la classe che verrà usata!!'''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Class HumanCaptchaCatcher
Public Shared Function
getCaptcha(ByVal img As Drawing.Image) As String
Dim bz As
New CHPTDialog(img)
bz.ShowDialog()
Return bz.Result
'your
code here
End Function
End Class