• Da ich mal wieder langeweile hatte und was neues in Sachen AutoIt suchte, habe ich zwei kleine Captcha Funktionen geschrieben:

    Beispiel
    [autoit]

    ;Test: _captcha
    $cap1 = _captcha(500, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", "_captcha Test")
    If $cap1 = True Then
    MsgBox(0, "_captcha", "Richtiges Captcha eingegeben oder das Fenster wurde vorzeitig geschlossen (Rückgabe: True)")
    Else
    MsgBox(0, "_captcha", "Falsches Captcha eingegeben (Rückgabe: False)")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;Test: _captchaEmb
    $form = GUICreate("_captchaEmb Test", 292, 55, 192, 124)
    $pic = GUICtrlCreatePic("", 0, 0, 292, 55)
    $cap2 = _captchaEmb($form, $pic)
    WinSetTitle($form, "", "_captchaEmb Test (" & $cap2 & ")")
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    If GUIGetMsg() = -3 Then Exit
    WEnd

    [/autoit]
    UDF
    [autoit]

    #include <GDIPlus.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ;Danke an ProgAndy für die Hilfestellung bei GDI+ :)
    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _captchaEmb
    ; Description ...: Erstellt ein Captcha in einem Picc-controll
    ; Syntax.........: _captchaEmb($hWnd, $hPic, $iPoints = 500, $sLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", $sTitle = "Captcha", $sMsg = "Please insert the Code in the picture:", $sFont = "Times New Roman", $iSize = 10, $bBold = True)
    ; Parameters ....: $hWnd - Handle des Fenster indem sich das Pic-controll befindet
    ; $hPic - Handle des Pic-controlls
    ; $iPoints - Punkte die über die Schrift gezeichnet werden
    ; $sLetters - Buchstaben die im Captcha verwendet werden sollen
    ; $sTitle - Der Titel des Fensters
    ; $iMsg - Die Nachricht die im Fenster erscheind
    ; $sFont - Schriftart in der die Buchstaben geschrieben werden sollen
    ; $iSize - Schriftgröße in der die Buchstaben geschrieben werden sollen
    ; $bBold - Schrift dick schreiben (True - Ja;False - Nein)
    ; Return values .: Erfolg - Gibt den Captchacode zurück
    ; Fehler - Gibt -1 zurück und setzt @error auf 1
    ; Author ........: Carsten8
    ; Remarks .......: Das Bild wird in der Breite 292 und der Höhe 55 erstellt!
    ; ===============================================================================================================================
    Func _captchaEmb($hWnd, $hPic, $iPoints = 500, $sLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", $sTitle = "Captcha", $sMsg = "Please insert the Code in the picture:", $sFont = "Times New Roman", $iSize = 10, $bBold = True)
    Local $iLen = 10, $sCaptcha
    For $i = 1 To $iLen
    $sCaptcha &= StringMid($sLetters, Random(1, StringLen($sLetters)), 1)
    Next
    If Not IsHWnd($hWnd) Then
    SetError(1)
    Return -1
    EndIf
    _GDIPlus_Startup()
    $capGraph = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBMP = _GDIPlus_BitmapCreateFromGraphics(292,55,$capGraph)
    _GDIPlus_GraphicsDispose($capGraph)
    $capGraph = _GDIPlus_ImageGetGraphicsContext($hBMP)
    _GDIPlus_GraphicsFillRect($capGraph, 0, 0, 292, 55, _GDIPlus_BrushCreateSolid(0xFFFEFEFE))
    For $iL = 1 To $iLen
    $rand = Random(0, 40)
    _GDIPlus_GraphicsDrawString($capGraph, StringMid($sCaptcha, $iL, 1), $iL * 25, $rand, $sFont, $iSize)
    If $bBold = True Then _GDIPlus_GraphicsDrawString($capGraph, StringMid($sCaptcha, $iL, 1), $iL * 25 + 1, $rand, $sFont, $iSize)
    Next
    For $capLines = 1 To $iPoints
    $randx = Random(0, 292)
    $randy = Random(0, 55)
    _GDIPlus_GraphicsDrawLine($capGraph, $randx, $randy, $randx + 1, $randy + 1)
    Next
    $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP)
    _SetBitmapToCtrl($hPic, $hBitmap_GDI)
    _GDIPlus_GraphicsDispose($capGraph)
    _GDIPlus_BitmapDispose($hBMP)
    _GDIPlus_Shutdown()
    Return $sCaptcha
    EndFunc
    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _captcha
    ; Description ...: Erstellt ein Fenster mit einem Captcha.
    ; Syntax.........: _captcha($iPoints = 500, $sLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", $sTitle = "Captcha", $sMsg = "Please insert the Code in the picture:", $sFont = "Times New Roman", $iSize = 10, $bBold = True)
    ; Parameters ....: $iPoints - Punkte die über die Schrift gezeichnet werden
    ; $sLetters - Buchstaben die im Captcha verwendet werden sollen
    ; $sTitle - Der Titel des Fensters
    ; $iMsg - Die Nachricht die im Fenster erscheind
    ; $sFont - Schriftart in der die Buchstaben geschrieben werden sollen
    ; $iSize - Schriftgröße in der die Buchstaben geschrieben werden sollen
    ; $bBold - Schrift dick schreiben (True - Ja;False - Nein)
    ; Return values .: Richtiges Captcha - True
    ; Falsches Captcha - False
    ; Author ........: Carsten8
    ; Remarks .......: Gibt auch False zurück wenn das Fenster vom Benutzer geschlossen wurde.
    ; ===============================================================================================================================
    Func _captcha($iPoints = 500, $sLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", $sTitle = "Captcha", $sMsg = "Please insert the Code in the picture:", $sFont = "Times New Roman", $iSize = 10, $bBold = True)
    Local $iLen = 10, $sCaptcha
    For $i = 1 To $iLen
    $sCaptcha &= StringMid($sLetters, Random(1, StringLen($sLetters)), 1)
    Next
    $capWin = GUICreate($sTitle, 309, 164, 303, 235)
    GUICtrlCreateLabel($sMsg, 4, 4, 300, 17)
    GUICtrlCreateGroup("Captcha", 4, 24, 300, 77)
    $capPic = GUICtrlCreatePic("",8,40,292,55)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $capIn = GUICtrlCreateInput("", 4, 104, 300, 21)
    $capOK = GUICtrlCreateButton("OK", 120, 132, 75, 25, 0)
    GUISetState(@SW_SHOW, $capWin)
    _GDIPlus_Startup()
    $capGraph = _GDIPlus_GraphicsCreateFromHWND($capWin)
    $hBMP = _GDIPlus_BitmapCreateFromGraphics(292,55,$capGraph)
    _GDIPlus_GraphicsDispose($capGraph)
    $capGraph = _GDIPlus_ImageGetGraphicsContext($hBMP)
    _GDIPlus_GraphicsFillRect($capGraph, 0, 0, 292, 55, _GDIPlus_BrushCreateSolid(0xFFFEFEFE))
    For $iL = 1 To $iLen
    $rand = Random(0, 40)
    _GDIPlus_GraphicsDrawString($capGraph, StringMid($sCaptcha, $iL, 1), $iL * 25, $rand, $sFont, $iSize)
    If $bBold = True Then _GDIPlus_GraphicsDrawString($capGraph, StringMid($sCaptcha, $iL, 1), $iL * 25 + 1, $rand, $sFont, $iSize)
    Next
    For $capLines = 1 To $iPoints
    $randx = Random(0, 292)
    $randy = Random(0, 55)
    _GDIPlus_GraphicsDrawLine($capGraph, $randx, $randy, $randx + 1, $randy + 1)
    Next
    $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP)
    _SetBitmapToCtrl($capPic, $hBitmap_GDI)
    _GDIPlus_GraphicsDispose($capGraph)
    _GDIPlus_BitmapDispose($hBMP)
    _GDIPlus_Shutdown()
    While 1
    $mGUI = GUIGetMsg(1)
    Switch $mGUI[0]
    Case -3
    GUIDelete($capWin)
    Return False
    Case $capOK
    If GUICtrlRead($capIn) = $sCaptcha Then
    GUIDelete($capWin)
    Return True
    Else
    GUIDelete($capWin)
    Return False
    EndIf
    EndSwitch
    WEnd
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _SetBitmapToCtrl($CtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0xE
    Local Const $GWL_STYLE = -16

    [/autoit] [autoit][/autoit] [autoit]

    Local $hWnd = GUICtrlGetHandle($CtrlId)
    If $hWnd = 0 Then Return SetError(1, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE)
    If @error Then Return SetError(2, 0, 0)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP))
    If @error Then Return SetError(3, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $oldBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hBitmap)
    If @error Then Return SetError(4, 0, 0)
    If $oldBmp[0] <> 0 Then DllCall("GDI32.dll", "int", "DeleteObject", "int", $oldBmp[0])
    Return 1
    EndFunc

    [/autoit]


    Freue mich auf Kritik und Kommentare dazu :)
    Es ist meine erste Funktion in der GDI+ vorkommt und die erste Funktion die ich veröffentliche, seid also nicht allzu pingelich :thumbup:

    Gruß
    Carsten

    5 Mal editiert, zuletzt von Carsten8 (4. Januar 2009 um 19:44)

  • Also, der Aufraümcode wird gar nicht aufgerufen ;)
    Zeile 67, 68 und 69 vor dir Schleife verschieben und Zeile 66 ganz löschen ;) (Das Bild wird gelöscht, wenn das GUICtrlPic gelöscht wird)
    Außerdem muss vor jedes Return ein GUIDelete .

  • Die GUI wird immer noch noocht gelöscht, wenn man auf OK klickt ;) Also z.B. so machen:

    [autoit]

    Case $capOK
    Local $read = GUICtrlRead($capIn)
    GUIDelete($capWin)
    If $read = $sCaptcha Then

    [/autoit]
  • Hallo & Moin-Moin.

    Hat jemand ein Anwendungsbeispiel?
    Bei mir will das nicht laufen.

    Danke bereits an dieser Stelle.

    LG,
    Alina.

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl

  • Hier :D :

    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    AutoIt Version: 3.3.0.0
    Author: myName

    [/autoit] [autoit][/autoit] [autoit]

    Script Function:
    Template AutoIt script.

    [/autoit] [autoit][/autoit] [autoit]

    #ce ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    ; Script Start - Add your code below here

    [/autoit] [autoit][/autoit] [autoit]

    #include <GDIPlus.au3>
    #include <WinAPI.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 633, 447, 193, 125)
    $getcaptcha = _captcha()
    If $getcaptcha = False Then Exit
    $Button1 = GUICtrlCreateButton("Button1", 128, 72, 75, 25, 0)
    $Input1 = GUICtrlCreateInput("Input1", 96, 160, 121, 21)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Danke an ProgAndy für die Hilfestellung bei GDI+ :)
    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _captcha
    ; Description ...: Erstellt ein Fenster mit einem Captcha.
    ; Syntax.........: _captcha($iPoints = 500, $sLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", $sTitle = "Captcha", $sMsg = "Please insert the Code in the picture:", $sFont = "Times New Roman", $iSize = 10, $bBold = True)
    ; Parameters ....: $iPoints - Punkte die über die Schrift gezeichnet werden
    ; $sLetters - Buchstaben die im Captcha verwendet werden sollen
    ; $sTitle - Der Titel des Fensters
    ; $iMsg - Die Nachricht die im Fenster erscheind
    ; $sFont - Schriftart in der die Buchstaben geschrieben werden sollen
    ; $iSize - Schriftgröße in der die Buchstaben geschrieben werden sollen
    ; $bBold - Schrift dick schreiben (True - Ja;False - Nein)
    ; Return values .: Richtiges Captcha - True
    ; Falsches Captcha - False
    ; Author ........: Carsten8
    ; Remarks .......: Gibt auch False zurück wenn das Fenster vom Benutzer geschlossen wurde.
    ; ===============================================================================================================================
    Func _captcha($iPoints = 500, $sLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", $sTitle = "Captcha", $sMsg = "Please insert the Code in the picture:", $sFont = "Times New Roman", $iSize = 10, $bBold = True)
    Local $iLen = 10, $sCaptcha
    For $i = 1 To $iLen
    $sCaptcha &= StringMid($sLetters, Random(1, StringLen($sLetters)), 1)
    Next
    $capWin = GUICreate($sTitle, 309, 164, 303, 235)
    GUICtrlCreateLabel($sMsg, 4, 4, 300, 17)
    GUICtrlCreateGroup("Captcha", 4, 24, 300, 77)
    $capPic = GUICtrlCreatePic("",8,40,292,55)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $capIn = GUICtrlCreateInput("", 4, 104, 300, 21)
    $capOK = GUICtrlCreateButton("OK", 120, 132, 75, 25, 0)
    GUISetState(@SW_SHOW, $capWin)
    _GDIPlus_Startup()
    $capGraph = _GDIPlus_GraphicsCreateFromHWND($capWin)
    $hBMP = _GDIPlus_BitmapCreateFromGraphics(292,55,$capGraph)
    _GDIPlus_GraphicsDispose($capGraph)
    $capGraph = _GDIPlus_ImageGetGraphicsContext($hBMP)
    _GDIPlus_GraphicsFillRect($capGraph, 0, 0, 292, 55, _GDIPlus_BrushCreateSolid(0xFFFEFEFE))
    For $iL = 1 To $iLen
    $rand = Random(0, 40)
    _GDIPlus_GraphicsDrawString($capGraph, StringMid($sCaptcha, $iL, 1), $iL * 25, $rand, $sFont, $iSize)
    If $bBold = True Then _GDIPlus_GraphicsDrawString($capGraph, StringMid($sCaptcha, $iL, 1), $iL * 25 + 1, $rand, $sFont, $iSize)
    Next
    For $capLines = 1 To $iPoints
    $randx = Random(0, 292)
    $randy = Random(0, 55)
    _GDIPlus_GraphicsDrawLine($capGraph, $randx, $randy, $randx + 1, $randy + 1)
    Next
    $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP)
    _SetBitmapToCtrl($capPic, $hBitmap_GDI)
    _GDIPlus_GraphicsDispose($capGraph)
    _GDIPlus_BitmapDispose($hBMP)
    _GDIPlus_Shutdown()
    While 1
    $mGUI = GUIGetMsg(1)
    Switch $mGUI[0]
    Case -3
    GUIDelete($capWin)
    Return False
    Case $capOK
    If GUICtrlRead($capIn) = $sCaptcha Then
    GUIDelete($capWin)
    Return True
    Else
    GUIDelete($capWin)
    Return False
    EndIf
    EndSwitch
    WEnd
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _SetBitmapToCtrl($CtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0xE
    Local Const $GWL_STYLE = -16

    [/autoit] [autoit][/autoit] [autoit]

    Local $hWnd = GUICtrlGetHandle($CtrlId)
    If $hWnd = 0 Then Return SetError(1, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE)
    If @error Then Return SetError(2, 0, 0)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP))
    If @error Then Return SetError(3, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $oldBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hBitmap)
    If @error Then Return SetError(4, 0, 0)
    If $oldBmp[0] <> 0 Then DllCall("GDI32.dll", "int", "DeleteObject", "int", $oldBmp[0])
    Return 1
    EndFunc

    [/autoit]
  • Vielen DANK !!!

    Aber auch wenn man nichts ein gibt kommt man weiter. ;)

    Würde in Zeile 82 den Wert 40 auf 30 setzen. So rutschen keine Buchstaben zu weit runter
    Also so: $rand = Random(0, 30).

    LG,
    Alina.

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl

    Einmal editiert, zuletzt von Alina (2. Januar 2009 um 16:03)

  • Hallo twister.
    Also ich habe das Beispiel genutzt das Deepred gepostet hat und da ist es egal was man in das Feld schreibt oder ob man überhaupt was rein schreibt. Immer kommt das GUI, was doch eigentlich erst erscheinen soll, wenn die Eingabe einwandfrei ist, oder?

    LG,
    Alina.

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl

  • Bei mir klappt es aber.

    Funkt es damit?
    Hier nochmal:

    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    AutoIt Version: 3.3.0.0
    Author: myName

    [/autoit] [autoit][/autoit] [autoit]

    Script Function:
    Template AutoIt script.

    [/autoit] [autoit][/autoit] [autoit]

    #ce ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    ; Script Start - Add your code below here

    [/autoit] [autoit][/autoit] [autoit]

    #include <GDIPlus.au3>
    #include <WinAPI.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 633, 447, 193, 125)
    $getcaptcha = _captcha()
    If $getcaptcha = False Then Exit
    $Button1 = GUICtrlCreateButton("Button1", 128, 72, 75, 25, 0)
    $Input1 = GUICtrlCreateInput("Input1", 96, 160, 121, 21)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Danke an ProgAndy für die Hilfestellung bei GDI+ :)
    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _captcha
    ; Description ...: Erstellt ein Fenster mit einem Captcha.
    ; Syntax.........: _captcha($iPoints = 500, $sLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", $sTitle = "Captcha", $sMsg = "Please insert the Code in the picture:", $sFont = "Times New Roman", $iSize = 10, $bBold = True)
    ; Parameters ....: $iPoints - Punkte die über die Schrift gezeichnet werden
    ; $sLetters - Buchstaben die im Captcha verwendet werden sollen
    ; $sTitle - Der Titel des Fensters
    ; $iMsg - Die Nachricht die im Fenster erscheind
    ; $sFont - Schriftart in der die Buchstaben geschrieben werden sollen
    ; $iSize - Schriftgröße in der die Buchstaben geschrieben werden sollen
    ; $bBold - Schrift dick schreiben (True - Ja;False - Nein)
    ; Return values .: Richtiges Captcha - True
    ; Falsches Captcha - False
    ; Author ........: Carsten8
    ; Remarks .......: Gibt auch False zurück wenn das Fenster vom Benutzer geschlossen wurde.
    ; ===============================================================================================================================
    Func _captcha($iPoints = 500, $sLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", $sTitle = "Captcha", $sMsg = "Please insert the Code in the picture:", $sFont = "Times New Roman", $iSize = 10, $bBold = True)
    Local $iLen = 10, $sCaptcha
    For $i = 1 To $iLen
    $sCaptcha &= StringMid($sLetters, Random(1, StringLen($sLetters)), 1)
    Next
    $capWin = GUICreate($sTitle, 309, 164, 303, 235)
    GUICtrlCreateLabel($sMsg, 4, 4, 300, 17)
    GUICtrlCreateGroup("Captcha", 4, 24, 300, 77)
    $capPic = GUICtrlCreatePic("",8,40,292,55)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $capIn = GUICtrlCreateInput("", 4, 104, 300, 21)
    $capOK = GUICtrlCreateButton("OK", 120, 132, 75, 25, 0)
    GUISetState(@SW_SHOW, $capWin)
    _GDIPlus_Startup()
    $capGraph = _GDIPlus_GraphicsCreateFromHWND($capWin)
    $hBMP = _GDIPlus_BitmapCreateFromGraphics(292,55,$capGraph)
    _GDIPlus_GraphicsDispose($capGraph)
    $capGraph = _GDIPlus_ImageGetGraphicsContext($hBMP)
    _GDIPlus_GraphicsFillRect($capGraph, 0, 0, 292, 55, _GDIPlus_BrushCreateSolid(0xFFFEFEFE))
    For $iL = 1 To $iLen
    $rand = Random(0, 40)
    _GDIPlus_GraphicsDrawString($capGraph, StringMid($sCaptcha, $iL, 1), $iL * 25, $rand, $sFont, $iSize)
    If $bBold = True Then _GDIPlus_GraphicsDrawString($capGraph, StringMid($sCaptcha, $iL, 1), $iL * 25 + 1, $rand, $sFont, $iSize)
    Next
    For $capLines = 1 To $iPoints
    $randx = Random(0, 292)
    $randy = Random(0, 55)
    _GDIPlus_GraphicsDrawLine($capGraph, $randx, $randy, $randx + 1, $randy + 1)
    Next
    $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP)
    _SetBitmapToCtrl($capPic, $hBitmap_GDI)
    _GDIPlus_GraphicsDispose($capGraph)
    _GDIPlus_BitmapDispose($hBMP)
    _GDIPlus_Shutdown()
    While 1
    $mGUI = GUIGetMsg(1)
    Switch $mGUI[0]
    Case -3
    GUIDelete($capWin)
    Return False
    Case $capOK
    If GUICtrlRead($capIn) = $sCaptcha Then
    GUIDelete($capWin)
    Return True
    Else
    GUIDelete($capWin)
    Return False
    EndIf
    EndSwitch
    WEnd
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _SetBitmapToCtrl($CtrlId, $hBitmap)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $SS_BITMAP = 0xE
    Local Const $GWL_STYLE = -16

    [/autoit] [autoit][/autoit] [autoit]

    Local $hWnd = GUICtrlGetHandle($CtrlId)
    If $hWnd = 0 Then Return SetError(1, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE)
    If @error Then Return SetError(2, 0, 0)
    DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP))
    If @error Then Return SetError(3, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $oldBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hWnd, "int", $STM_SETIMAGE, "int", $IMAGE_BITMAP, "int", $hBitmap)
    If @error Then Return SetError(4, 0, 0)
    If $oldBmp[0] <> 0 Then DllCall("GDI32.dll", "int", "DeleteObject", "int", $oldBmp[0])
    Return 1
    EndFunc

    [/autoit]
  • EINWANDFREI !!!

    LG,
    Alina.

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl