AutoIt Absturz nach Progress

  • Habe heute 3 Progress mithilfe von Prog@ndy's UDF erstellt (klick) Habe jetzt nur das Problem, dass AutoIt abstürzt, wenn Exit angewendet wird. Bei der kompilierten Version hängt sich das Programm einfach auf. Das habe ich erst, seitdem die Progresse enthalten sind, das lustige ist aber, dass diese perfekt funktionieren. Ich beende die Progresse auch ordnungsgemäß. Source kann ich so nicht geben weil sonst das Geschrei wieder anfängt, dass es ein Bot oder so ist (was es nicht ist aber es gibt oft genug Meinungsverschiedenheiten). Das Beispielscript funktioniert auch wunderbar. Woran könnte soetwas liegen? Weiß jetzt nicht, was ich noch für Infos geben könnte, einfach fragen...

    Danke

    • Offizieller Beitrag

    Hokus,Pokus, Fidibus. Shit , bin nicht so gut im herbeizaubern meiner Glaskugel. 8| Da mußt du schon helfen. Code bitte .

  • Aufgrund einer bisheriger Verwarnung in einem ähnlichen Beitrag habe ich den Code erstmal weggelassen.

    Script:

    GDIpProgress.au3:

    Spoiler anzeigen
    [autoit]

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

    AutoIt Version: 3.2.12.0
    Author: Prog@ndy
    after Script from nobbe ( 2008 in http://www.autoitscript.com/forum/index.ph…ndpost&p=485031 )

    Script Function: A UDF for colored Progressbars with GDIPlus

    Remarks: Theres an example from Line 22 to line 112 ( between the first #Region - #Endregion Tags

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

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

    #include-once
    #include <GuiConstants.au3>
    #include <WIndowsConstants.au3>
    #include <EditConstants.au3>
    #include <WinApi.au3>
    #include <GdiPlus.au3>

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

    Global $_Progress_ahCallBack[3] = [-1, -1, 0], $_Progress_Bars[1][15] = [[-1]], $iPercent = 0;

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

    #EndRegion EXAMPLE
    ;##################################################

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

    ;-------------------------------------------------------------------
    #Region Colored Progressbar
    ;===============================================================================
    ;
    ; Function Name: _ProgressCreate
    ; Description:: Creates a GDIplus Progressbar
    ; Parameter(s): $x : left
    ; $y : top
    ; $w : width
    ; $h : height
    ; $Col : [Optional] Top color of the foreground gradient
    ; $GradCol : [Optional] Bottom color of the foreground gradient
    ; $BG : [Optional] Top color of the background gradient
    ; $GradBG : [Optional] Bottom color of the background gradient
    ; Requirement(s): GDIplus
    ; Return Value(s): Success: ID of Progressbar, Error: 0
    ; Author(s): Prog@ndy
    ;
    ;===============================================================================
    ;
    Func _ProgressCreate($x, $y, $w = 204, $h = 24, $Col = 0xFFFF00, $GradCol = 0x00FF00, $BG = 0xAAAA00, $GradBG = 0xFF0000)
    __CheckForGDIPlus()
    $ID = UBound($_Progress_Bars)
    ReDim $_Progress_Bars[$ID + 1][15]
    $_Progress_Bars[$ID][0] = GUICtrlCreateLabel("", $x, $y, $w, $h)
    GUICtrlSetBkColor($_Progress_Bars[$ID][0], -2) ; $GUI_BKCOLOR_TRANSPARENT = -2
    If @error Then Return SetError(@error, @extended, 0)
    If $Col = -1 Then $Col = 0xFFFF00
    If $BG = -1 Then $BG = 0xAAAA00
    If $GradCol = -1 Then $GradCol = 0x00FF00
    If $GradBG = -1 Then $GradBG = 0xFF0000
    _GDIPlus_Startup()
    Local $graphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($_Progress_Bars[$ID][0]))
    Local $bitmap = _GDIPlus_BitmapCreateFromGraphics($w, $h, $graphic)
    Local $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

    Local $bmpfront = _GDIPlus_BitmapCreateFromGraphics($w, $h, $graphic)
    _CreateGradientImg($bmpfront, $w - 1, $h - 1, $Col, $GradCol)
    $_Progress_Bars[$ID][11] = _GDIPlus_ImageGetWidth($bmpfront)
    $_Progress_Bars[$ID][12] = _GDIPlus_ImageGetHeight($bmpfront)

    Local $bmpBack = _GDIPlus_BitmapCreateFromGraphics($w, $h, $graphic)
    _CreateGradientImg($bmpBack, $w - 1, $h - 1, $BG, $GradBG)
    $_Progress_Bars[$ID][13] = _GDIPlus_ImageGetWidth($bmpBack)
    $_Progress_Bars[$ID][14] = _GDIPlus_ImageGetHeight($bmpBack)

    $_Progress_Bars[$ID][1] = $w
    $_Progress_Bars[$ID][2] = $h

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

    $_Progress_Bars[$ID][3] = $graphic
    $_Progress_Bars[$ID][4] = $bitmap
    $_Progress_Bars[$ID][5] = $backbuffer
    $_Progress_Bars[$ID][6] = $bmpfront
    $_Progress_Bars[$ID][7] = $bmpBack
    $_Progress_Bars[$ID][8] = 0
    $_Progress_Bars[$ID][9] = 1
    $_Progress_Bars[$ID][10] = "Arial|10|1|0xFF000000"
    _ProgressRefresh($ID, 0)
    _Progress_CallBack_Init()
    Return SetError(0, 0, $ID)
    EndFunc ;==>_ProgressCreate

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

    ;===============================================================================
    ;
    ; Function Name: _ProgressDelete
    ; Description:: Deletes a GDI+ Progressbar
    ; Parameter(s): $ID : ID of Progressbar
    ; Requirement(s): GDIplus
    ; Return Value(s): Sucess: 1, Error: 0
    ; Author(s): Prog@ndy
    ;
    ;===============================================================================
    ;
    Func _ProgressDelete(ByRef $ID)
    If Not IsArray($_Progress_Bars) Or UBound($_Progress_Bars, 2) <> 15 Or UBound($_Progress_Bars) < ($ID - 1) Then Return SetError(1, 0, 0)
    _Progress_CallBack_Free()
    Local $temp[9],$i
    FoR $i = 0 To 8
    $temp[$i] = $_Progress_Bars[$ID][$i]
    Next
    $_Progress_Bars[$ID][0] = -1
    Local $ret = GUICtrlDelete($temp[0])
    If @error Then Return SetError(1,0,0)
    $_Progress_Bars[$ID][1] = -1
    $_Progress_Bars[$ID][2] = -1

    $_Progress_Bars[$ID][3] = -1
    _GDIPlus_GraphicsDispose($temp[3])
    Local $error = @error
    $_Progress_Bars[$ID][4] = -1
    _WinAPI_DeleteObject($temp[4])
    Local $error = @error
    $_Progress_Bars[$ID][5] = -1
    _GDIPlus_GraphicsDispose($temp[5])
    Local $error = @error
    $_Progress_Bars[$ID][6] = -1
    _WinAPI_DeleteObject($temp[6])
    Local $error = @error
    _GDIPlus_ImageDispose($temp[6])
    Local $error = @error
    $_Progress_Bars[$ID][7] = -1
    _WinAPI_DeleteObject($temp[7])
    Local $error = @error
    _GDIPlus_ImageDispose($temp[7])
    $_Progress_Bars[$ID][8] = -1


    _GDIPlus_Shutdown()
    Return SetError($error, 0, $error=0)
    EndFunc ;==>_ProgressDelete

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

    ;===============================================================================
    ;
    ; Function Name: _ProgressSetColors(
    ; Description:: Sets gradients as foreground and background
    ; Parameter(s): $ID : ID of Progressbar
    ; $Col : Top color of the foreground gradient
    ; $GradCol : Bottom color of the foreground gradient
    ; $BG : Top color of the background gradient
    ; $GradBG : Bottom color of the background gradient
    ; If $Col or $GradCol is -1, the foreground gradient isn't changed
    ; If $BG or $GradBG is -1, the background gradient isn't changed
    ; Requirement(s): Winapi.au3, GDIplus
    ; Return Value(s): Success: 1, Error: 0
    ; Author(s): Prog@ndy
    ;
    ;===============================================================================
    ;
    Func _ProgressSetColors(ByRef $ID, $Col = -1, $GradCol = -1, $BG = -1, $GradBG = -1)
    If Not IsArray($_Progress_Bars) Or UBound($_Progress_Bars, 2) <> 15 Or UBound($_Progress_Bars) < ($ID - 1) Then Return SetError(1, 0, 0)
    If Execute($Col) > -1 And Execute($GradCol) > -1 Then
    _WinAPI_DeleteObject($_Progress_Bars[$ID][6])
    _GDIPlus_ImageDispose($_Progress_Bars[$ID][6])
    $_Progress_Bars[$ID][6] = _GDIPlus_BitmapCreateFromGraphics($_Progress_Bars[$ID][1], $_Progress_Bars[$ID][2], $_Progress_Bars[$ID][3])
    _CreateGradientImg($_Progress_Bars[$ID][6], $_Progress_Bars[$ID][1] - 1, $_Progress_Bars[$ID][2] - 1, $Col, $GradCol)
    $_Progress_Bars[$ID][11] = $_Progress_Bars[$ID][1]
    $_Progress_Bars[$ID][12] = $_Progress_Bars[$ID][2]
    EndIf
    If Execute($BG) > -1 And Execute($GradBG) > -1 Then
    _WinAPI_DeleteObject($_Progress_Bars[$ID][7])
    _GDIPlus_ImageDispose($_Progress_Bars[$ID][7])
    $_Progress_Bars[$ID][7] = _GDIPlus_BitmapCreateFromGraphics($_Progress_Bars[$ID][1], $_Progress_Bars[$ID][2], $_Progress_Bars[$ID][3])
    _CreateGradientImg($_Progress_Bars[$ID][7], $_Progress_Bars[$ID][1] - 1, $_Progress_Bars[$ID][2] - 1, $BG, $GradBG)
    $_Progress_Bars[$ID][13] = $_Progress_Bars[$ID][1]
    $_Progress_Bars[$ID][14] = $_Progress_Bars[$ID][2]
    EndIf
    ;~ _ProgressSet($ID, $_Progress_Bars[$ID][8])
    Return SetError(@error, 0, @error = 0)
    EndFunc ;==>_ProgressSetColors

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

    ;===============================================================================
    ;
    ; Function Name: _ProgressSetImages(
    ; Description:: Sets images as foreground and background by Path
    ; Parameter(s): $ID : ID of Progressbar
    ; $ForeBmp : Path to image , empty String "" To leave the old
    ; The foreground image
    ; $BackBmp : [Optional] Path to image , empty String "" To leave the old
    ; The background image
    ; Requirement(s): Winapi.au3, GDIplus
    ; Return Value(s): Success: 1, Error: 0
    ; Author(s): Prog@ndy
    ;
    ;===============================================================================
    ;
    Func _ProgressSetImages(ByRef $ID, $ForeBmp = "", $backBMP = "")
    Local $bmp = ""
    If Not IsArray($_Progress_Bars) Or UBound($_Progress_Bars, 2) <> 15 Or UBound($_Progress_Bars) < ($ID - 1) Then Return SetError(1, 0, 0)
    If GUICtrlGetHandle($_Progress_Bars[$ID][0]) = 0 Then Return SetError(2, 0, 0)
    If $ForeBmp <> "" And FileExists($ForeBmp) Then
    $bmp = _GDIPlus_ImageLoadFromFile($ForeBmp)
    If Not @error Then
    _WinAPI_DeleteObject($_Progress_Bars[$ID][6])
    _GDIPlus_ImageDispose($_Progress_Bars[$ID][6])
    $_Progress_Bars[$ID][6] = $bmp
    $_Progress_Bars[$ID][11] = _GDIPlus_ImageGetWidth($_Progress_Bars[$ID][6])
    $_Progress_Bars[$ID][12] = _GDIPlus_ImageGetHeight($_Progress_Bars[$ID][6])
    EndIf
    EndIf
    If $backBMP <> "" And FileExists($backBMP) Then
    $bmp = _GDIPlus_ImageLoadFromFile($backBMP)
    If Not @error Then
    _WinAPI_DeleteObject($_Progress_Bars[$ID][7])
    _GDIPlus_ImageDispose($_Progress_Bars[$ID][7])
    $_Progress_Bars[$ID][7] = $bmp
    $_Progress_Bars[$ID][13] = _GDIPlus_ImageGetWidth($_Progress_Bars[$ID][7])
    $_Progress_Bars[$ID][14] = _GDIPlus_ImageGetHeight($_Progress_Bars[$ID][7])
    EndIf
    EndIf
    ;~ _ProgressSet($ID, $_Progress_Bars[$ID][8])
    Return SetError(@error, 0, @error = 0)
    EndFunc ;==>_ProgressSetImages

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

    ;===============================================================================
    ;
    ; Function Name: _ProgressSetHBitmaps(
    ; Description:: Sets previously loaded GDIplus Images / bitmaps as foreground and background
    ; Parameter(s): $ID : ID of Progressbar
    ; $ForeBmp : Handle to GDIplus -image or -bitmap , -1 To leave the old
    ; The foreground image
    ; $BackBmp : [Optional] Handle to GDIplus -image or -bitmap , -1 To leave the old
    ; The background image
    ; Requirement(s): Winapi.au3, GDIplus
    ; Return Value(s): Success: 1, Error: 0
    ; Author(s): Prog@ndy
    ;
    ;===============================================================================
    ;
    Func _ProgressSetHBitmaps(ByRef $ID, $ForeBmp = -1, $backBMP = -1)
    If Not IsArray($_Progress_Bars) Or UBound($_Progress_Bars, 2) <> 15 Or UBound($_Progress_Bars) < ($ID - 1) Then Return SetError(1, 0, 0)
    If GUICtrlGetHandle($_Progress_Bars[$ID][1]) = 0 Then Return SetError(2, 0, 0)
    If $ForeBmp > -1 And _GDIPlus_ImageGetHeight($ForeBmp) Then
    _WinAPI_DeleteObject($_Progress_Bars[$ID][6])
    _GDIPlus_ImageDispose($_Progress_Bars[$ID][6])
    $_Progress_Bars[$ID][6] = $ForeBmp
    $_Progress_Bars[$ID][11] = _GDIPlus_ImageGetWidth($_Progress_Bars[$ID][6])
    $_Progress_Bars[$ID][12] = _GDIPlus_ImageGetHeight($_Progress_Bars[$ID][6])
    EndIf
    If $backBMP > -1 And _GDIPlus_ImageGetHeight($backBMP) Then
    _WinAPI_DeleteObject($_Progress_Bars[$ID][7])
    _GDIPlus_ImageDispose($_Progress_Bars[$ID][7])
    $_Progress_Bars[$ID][7] = $backBMP
    $_Progress_Bars[$ID][13] = _GDIPlus_ImageGetWidth($_Progress_Bars[$ID][7])
    $_Progress_Bars[$ID][14] = _GDIPlus_ImageGetHeight($_Progress_Bars[$ID][7])
    EndIf
    ;~ _ProgressSet($ID, $_Progress_Bars[$ID][8])
    Return SetError(@error, 0, @error = 0)
    EndFunc ;==>_ProgressSetHBitmaps

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

    ;===============================================================================
    ;
    ; Function Name: _ProgressSetText(
    ; Description:: Sets the text to be shown
    ; Parameter(s): $ID : ID of Progressbar
    ; $text: -> TRUE : Show percent
    ; -> A string to be shown, %P% is replaced with Percentage
    ; Requirement(s): This UDf
    ; Return Value(s): Success: 1, Error: 0
    ; Author(s): Prog@ndy
    ;
    ;===============================================================================
    ;
    Func _ProgressSetText(ByRef $ID, $text = True)
    If Not IsArray($_Progress_Bars) Or UBound($_Progress_Bars, 2) <> 15 Or UBound($_Progress_Bars) < ($ID - 1) Then Return SetError(1, 0, 0)
    $_Progress_Bars[$ID][9] = $text
    ;~ _ProgressSet($ID, $_Progress_Bars[$ID][8])
    Return SetError(@error, 0, @error = 0)
    EndFunc ;==>_ProgressSetText

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

    ;===============================================================================
    ;
    ; Function Name: _ProgressSetFont()
    ; Description:: Sets the Font and Color of the Text of the Progressbar
    ; Parameter(s): $ID : ID of Progressbar
    ; $Font : Name of the font (empty String "" to do not change)
    ; $size : [Optional] size of the font ( 0 or negative to leave the old)
    ; $Styles : [Optional] The style of the typeface. Can be a combination of the following:
    ; 0 - Normal weight or thickness of the typeface
    ; 1 - Bold typeface
    ; 2 - Italic typeface
    ; 4 - Underline
    ; 8 - Strikethrough
    ; ( -1, negative to leave the old)
    ; $ARGBcolor : [Optional] the color of the font, can be RGB or ARGB (depending on $isARGB)
    ; (empty String "" to do not change)
    ; $isARGB : [Optional] Sets, whether $ARGBcolor is RGB (False, default) or ARGB (True)
    ; Requirement(s): This UDF
    ; Return Value(s): Success: 1, Error: 0
    ; Author(s): Prog@ndy
    ;
    ;===============================================================================
    ;
    Func _ProgressSetFont(ByRef $ID, $Font, $size = Default, $Styles = Default, $ARGBcolor = Default, $isARGB = False)
    If Not IsArray($_Progress_Bars) Or UBound($_Progress_Bars, 2) <> 15 Or UBound($_Progress_Bars) < ($ID - 1) Then Return SetError(1, 0, 0)
    Local $array = StringSplit($_Progress_Bars[$ID][10], "|")
    If $Font <> "" And IsString($Font) And $Font <> Default Then $array[1] = $Font
    $size = Number($size)
    If $size > 0 And $size <> Default Then $array[2] = $size
    $Styles = Number($Styles)
    If $Styles > -1 And $Styles <> Default Then $array[3] = BitAND($Styles, 15)
    If Not $isARGB Then $ARGBcolor = "0xFF" & Hex($ARGBcolor, 6)
    If Not ($ARGBcolor == "") And Not ($ARGBcolor == Default) Then $array[4] = "0x" & Hex($ARGBcolor, 8)
    $_Progress_Bars[$ID][10] = $array[1] & "|" & $array[2] & "|" & $array[3] & "|" & $array[4]
    ;~ _ProgressSet($ID, $_Progress_Bars[$ID][8])
    Return SetError(@error, 0, @error = 0)
    EndFunc ;==>_ProgressSetFont

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

    ;===============================================================================
    ;
    ; Function Name: _ProgressSet()
    ; Description:: Sets the percentage of the Progressbar
    ; Parameter(s): $ID : ID of Progressbar
    ; $prc The percentage to set
    ; Requirement(s): This UDF :)
    ; Return Value(s): If Progressbar odes not Exist: @error is set to 1
    ; Author(s): Prog@ndy
    ;
    ;===============================================================================
    ;
    Func _ProgressSet(ByRef $ID, $prc)
    If Not IsArray($_Progress_Bars) Or UBound($_Progress_Bars, 2) <> 15 Or UBound($_Progress_Bars) < ($ID - 1) Then Return SetError(1, 0, 0)
    If $prc > 100 Then $prc = 100
    If $prc < 0 Then $prc = 0
    $_Progress_Bars[$ID][8] = $prc
    Return 1
    EndFunc ;==>_ProgressSet
    Func _ProgressGet(ByRef $ID)
    If Not IsArray($_Progress_Bars) Or UBound($_Progress_Bars, 2) <> 15 Or UBound($_Progress_Bars) < ($ID - 1) Then Return SetError(1, 0, 0)
    Return _WinAPI_LoWord($_Progress_Bars[$ID][8])
    EndFunc
    ;===============================================================================
    ;
    ; Function Name: _ProgressMarquee()
    ; Description:: Sets the
    ; Parameter(s): $ID : ID of Progressbar
    ; $speed : The speed of the Marquee: 1 to 10, smaller as 1 turns it off
    ; $makeSmallFront : Crop the Front image to 1/10 of its former width
    ; If it was created by _ProgressSetColors, this is 1/10 of Progress Width :)
    ; If this is set to -1 and $speed is set to < 0 then the Front image size is
    ; set to the width of the Progressbar
    ; Requirement(s): WinAPI
    ; Return Value(s): If Progressbar does not Exist: @error is set to 1
    ; Author(s): Prog@ndy
    ;
    ;===============================================================================
    ;
    Func _ProgressMarquee(ByRef $ID, $speed = 2, $makeSmallFront = 1)
    If Not IsArray($_Progress_Bars) Or UBound($_Progress_Bars, 2) <> 15 Or UBound($_Progress_Bars) < ($ID - 1) Then Return SetError(1, 0, 0)
    If $speed < 0 Then
    $_Progress_Bars[$ID][8] = _WinAPI_LoWord($_Progress_Bars[$ID][8])
    If $makeSmallFront = -1 Then $_Progress_Bars[$ID][11] = $_Progress_Bars[$ID][1]
    Return 1
    EndIf
    If $speed > 10 Then $speed = 10
    If $speed < 1 Then $speed = 1
    $_Progress_Bars[$ID][8] = _WinAPI_MakeLong(_WinAPI_LoWord($_Progress_Bars[$ID][8]), Number($speed))
    If $makeSmallFront Then $_Progress_Bars[$ID][11] = Int($_Progress_Bars[$ID][11] / 10)
    Return 1
    EndFunc ;==>_ProgressMarquee

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

    ; Author(s): Prog@ndy
    Func _ProgressRefresh(ByRef $ID, $prc = Default)
    If Not IsArray($_Progress_Bars) Or UBound($_Progress_Bars, 2) <> 15 Or UBound($_Progress_Bars) < ($ID - 1) Then Return SetError(1, 0, 0)
    If $_Progress_Bars[$ID][1] < 1 Then Return SetError(2, 0, 0)
    Local $bar_height = $_Progress_Bars[$ID][2] - 1
    Local $bar_width = $_Progress_Bars[$ID][1] - 1
    If $prc = Default Then $prc = $_Progress_Bars[$ID][8]
    If $_Progress_Bars[$ID][8] > 65535 Then Return _ProgressRefreshMarquee($ID)
    If $prc > 100 Then $prc = 100
    If $prc < 0 Then $prc = 0
    $_Progress_Bars[$ID][8] = $prc
    ;~ $iPercent = $prc
    ;~ ConsoleWrite($iPercent & @CRLF)
    ;~ GUICtrlSetData($Status_Label, $prc & "%")
    Local $position_in_bar = ($bar_width) / 100 * $prc ;; or we move out the bar
    If $prc = 0 Then $position_in_bar = 0
    _GDIPlus_GraphicsClear($_Progress_Bars[$ID][5], 0xFFFFFFFF)
    ;; draw blue bar from left
    If $position_in_bar > 0 Then _GDIPlus_GraphicsDrawImageRectRect($_Progress_Bars[$ID][5], $_Progress_Bars[$ID][6], _
    0, 0, Int(($_Progress_Bars[$ID][11] / 100) * $prc), $_Progress_Bars[$ID][12], _
    0, _
    0, _
    $position_in_bar, _
    $bar_height)
    ; draw grey bar to right side
    _GDIPlus_GraphicsDrawImageRectRect($_Progress_Bars[$ID][5], $_Progress_Bars[$ID][7], Int(($_Progress_Bars[$ID][13] / 100) * $prc), 0, Int(($_Progress_Bars[$ID][13] / 100) * (100 - $prc)), $_Progress_Bars[$ID][14], _
    $position_in_bar, _
    0, _
    $bar_width - $position_in_bar + 1, _
    $bar_height);

    If Not IsString($_Progress_Bars[$ID][9]) And $_Progress_Bars[$ID][9] = True Then
    _DrawStringCenter($_Progress_Bars[$ID][5], $prc & "%", $bar_width, $bar_height, $_Progress_Bars[$ID][10])
    ElseIf StringLen($_Progress_Bars[$ID][9]) > 0 Then
    _DrawStringCenter($_Progress_Bars[$ID][5], StringReplace($_Progress_Bars[$ID][9], "%P%", $prc), $bar_width, $bar_height, $_Progress_Bars[$ID][10])
    EndIf
    ;~ _GDIPlus_GraphicsDrawString($_Progress_Bars[$ID][5],$prc & " %",Ceiling(($bar_width/2)-15),Ceiling(($bar_height/2)-5))
    _GDIPlus_GraphicsDrawImage($_Progress_Bars[$ID][3], $_Progress_Bars[$ID][4], 0, 0)

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

    EndFunc ;==>_ProgressRefresh

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

    ; Author(s): Prog@ndy
    Func _ProgressRefreshMarquee(ByRef $ID, $prc = Default)
    If Not IsArray($_Progress_Bars) Or UBound($_Progress_Bars, 2) <> 15 Or UBound($_Progress_Bars) < ($ID - 1) Then Return SetError(1, 0, 0)
    If $_Progress_Bars[$ID][1] < 1 Then Return SetError(2, 0, 0)
    Local $bar_height = $_Progress_Bars[$ID][2] - 1
    Local $bar_width = $_Progress_Bars[$ID][1] - 1
    If $prc = Default Then $prc = _WinAPI_LoWord($_Progress_Bars[$ID][8])
    If $prc > 100 Then $prc = 0
    If $prc < 0 Then $prc = 0
    $_Progress_Bars[$ID][8] = _WinAPI_MakeLong($prc + _WinAPI_HiWord($_Progress_Bars[$ID][8]), _WinAPI_HiWord($_Progress_Bars[$ID][8]))
    ;~ $iPercent = $prc
    ;~ ConsoleWrite($iPercent & @CRLF)
    ;~ GUICtrlSetData($Status_Label, $prc & "%")
    Local $position_in_bar = ($bar_width + ($bar_height / $_Progress_Bars[$ID][12] * $_Progress_Bars[$ID][11])) / 100 * $prc ;; or we move out the bar
    If $prc = 0 Then $position_in_bar = 0
    _GDIPlus_GraphicsClear($_Progress_Bars[$ID][5], 0xFFFFFFFF)
    ; draw grey bar to right side
    _GDIPlus_GraphicsDrawImageRectRect($_Progress_Bars[$ID][5], $_Progress_Bars[$ID][7], 0, 0, $_Progress_Bars[$ID][13], $_Progress_Bars[$ID][14], _
    0, _
    0, _
    $bar_width, _
    $bar_height);
    ;; draw blue bar from left
    If $position_in_bar > 0 Then _GDIPlus_GraphicsDrawImageRectRect($_Progress_Bars[$ID][5], $_Progress_Bars[$ID][6], _
    0, 0, $_Progress_Bars[$ID][11], $_Progress_Bars[$ID][12], _
    $position_in_bar - ($bar_height / $_Progress_Bars[$ID][12] * $_Progress_Bars[$ID][11]), _
    0, _
    $bar_height / $_Progress_Bars[$ID][12] * $_Progress_Bars[$ID][11], _
    $bar_height)
    If Not IsString($_Progress_Bars[$ID][9]) And $_Progress_Bars[$ID][9] = True Then
    _DrawStringCenter($_Progress_Bars[$ID][5], StringReplace(" ", " ", ".", Mod(@SEC, 5) + 1), $bar_width, $bar_height, $_Progress_Bars[$ID][10])
    ElseIf StringLen($_Progress_Bars[$ID][9]) > 0 Then
    _DrawStringCenter($_Progress_Bars[$ID][5], StringReplace($_Progress_Bars[$ID][9], "%P%", StringReplace(" ", " ", ".", Mod(@SEC, 5) + 1)), $bar_width, $bar_height, $_Progress_Bars[$ID][10])
    EndIf
    ;~ _GDIPlus_GraphicsDrawString($_Progress_Bars[$ID][5],$prc & " %",Ceiling(($bar_width/2)-15),Ceiling(($bar_height/2)-5))
    _GDIPlus_GraphicsDrawImage($_Progress_Bars[$ID][3], $_Progress_Bars[$ID][4], 0, 0)

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

    EndFunc ;==>_ProgressRefreshMarquee

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

    ; Author(s): Prog@ndy
    Func _DrawStringCenter(ByRef $hGraphic, $sString, $bar_width, $bar_height, $FontFormat = "Arial|12|1|0xFF000000")
    $FontFormat = StringSplit($FontFormat, "|")
    Local $hBrush = _GDIPlus_BrushCreateSolid($FontFormat[4])
    Local $hFormat = _GDIPlus_StringFormatCreate(0x0400)
    Local $hFamily = _GDIPlus_FontFamilyCreate($FontFormat[1])
    Local $hFont = _GDIPlus_FontCreate($hFamily, $FontFormat[2], $FontFormat[3])
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    DllStructSetData($aInfo[0], "X", Int(($bar_width - DllStructGetData($aInfo[0], "Width")) / 2))
    DllStructSetData($aInfo[0], "Y", Int(($bar_height - DllStructGetData($aInfo[0], "Height")) / 2))
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    EndFunc ;==>_DrawStringCenter

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

    ; Modified _Max() Function, directly included
    ; Author(s): Jeremy Landes <jlandes at landeserve dot com>
    Func _MyMax($nNum1, $nNum2)

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

    If Number($nNum1) > Number($nNum2) Then
    Return Number($nNum1)
    Else
    Return Number($nNum2)
    EndIf
    EndFunc ;==>_MyMax

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

    #EndRegion Colored Progressbar
    ;-------------------------------------------------------------------

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

    ;-------------------------------------------------------------------
    #Region Gradient
    ;===============================================================================
    ;
    ; Function Name: _Gradient($RGB_Color1 ,$RGB_Color2, $Count)
    ; Description:: Returns an Array of Gradient Colors
    ; Parameter(s): $RGB_Color1 : The Start-Color in RGB Hexadecimal
    ; $RGB_Color2 : The End-Color in RGB Hexadecimal
    ; $Count : The number of Colors in the Gradient
    ; Requirement(s):
    ; Return Value(s): An Array with the Colors
    ; Author(s): Prog@ndy
    ;
    ;===============================================================================
    ;

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

    Func _Gradient($RGB_Color1, $RGB_Color2, $Count, $ARGB = False)
    Local $Color1_R, $Color1_G, $Color1_B, $Color2_R, $Color2_G, $Color2_B, $NeuCol_R, $NeuCol_G, $NeuCol_B
    $ARGB = StringLeft("FF", 2 * $ARGB)
    $Color1_R = BitAND(BitShift($RGB_Color1, 16), 0xff)
    $Color1_G = BitAND(BitShift($RGB_Color1, 8), 0xff)
    $Color1_B = BitAND($RGB_Color1, 0xff)

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

    $Color2_R = BitAND(BitShift($RGB_Color2, 16), 0xff)
    $Color2_G = BitAND(BitShift($RGB_Color2, 8), 0xff)
    $Color2_B = BitAND($RGB_Color2, 0xff)

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

    $Count -= 1 ; 0-basiert !
    Dim $arColors[$Count + 1], $pos1

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

    For $i = 0 To $Count
    $pos1 = $Count - $i
    $NeuCol_R = ($Color1_R * $pos1 + $Color2_R * $i) / ($Count)
    $NeuCol_G = ($Color1_G * $pos1 + $Color2_G * $i) / ($Count)
    $NeuCol_B = ($Color1_B * $pos1 + $Color2_B * $i) / ($Count)
    $arColors[$i] = Execute('0x' & $ARGB & Hex($NeuCol_R, 2) & Hex($NeuCol_G, 2) & Hex($NeuCol_B, 2))
    Next
    Return $arColors
    EndFunc ;==>_Gradient

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

    ;Hilfsfunktion für doppelten Verlauf
    ; Author(s): Prog@ndy
    Func _ZwischenGrad($RGB_c, $ARGB = False)
    Local $c_R = BitAND(BitShift($RGB_c, 16), 0xff)
    Local $c_G = BitAND(BitShift($RGB_c, 8), 0xff)
    Local $c_B = BitAND($RGB_c, 0xff)
    $c_R = _MyMax(0, $c_R - 99)
    $c_G = _MyMax(0, $c_G - 99)
    $c_B = _MyMax(0, $c_B - 99)
    If $ARGB Then Return Dec("FF" & Hex($c_R, 2) & Hex($c_G, 2) & Hex($c_B, 2))
    Return Dec(Hex($c_R, 2) & Hex($c_G, 2) & Hex($c_B, 2))
    EndFunc ;==>_ZwischenGrad

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

    ; Author(s): Prog@ndy
    Func _CreateGradientImg(ByRef $bmpfront, $w, $h, $startRGB, $endRGB)
    Local $graph_front = _GDIPlus_ImageGetGraphicsContext($bmpfront)
    Local $hPen = _GDIPlus_PenCreate(0, 1)
    Local $Wechsel = Round((9 / 20) * $h)
    Local $temp = _Gradient($startRGB, $endRGB, 3)
    $temp = _ZwischenGrad($temp[1], 0)
    Local $Gradient = _Gradient($startRGB, $temp, $Wechsel, 1)
    Local $Gradient2 = _Gradient($temp, $endRGB, $h - $Wechsel, 1)
    Local $PenColor
    For $i = 0 To $h - 1
    If $i < $Wechsel Then
    $PenColor = $Gradient[$i]
    Else
    $PenColor = $Gradient2[$i - $Wechsel]
    EndIf
    _GDIPlus_PenSetColor($hPen, $PenColor)
    _GDIPlus_GraphicsDrawLine($graph_front, 0, $i, $w, $i, $hPen)
    Next
    _GDIPlus_PenSetColor($hPen, 0xFF666666)
    _GDIPlus_GraphicsDrawRect($graph_front, 0, 0, $w, $h, $hPen)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($graph_front)
    EndFunc ;==>_CreateGradientImg

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

    #EndRegion Gradient
    ;-------------------------------------------------------------------

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

    ;-------------------------------------------------------------------
    #Region Internal
    ; Internal Function, do not use !
    Func _Paint_Bars_Procedure($hWnd, $nMsg, $wParam, $lParam)
    For $i = 1 To UBound($_Progress_Bars) - 1
    If Not ($_Progress_Bars[$i][0] = -1) Then _ProgressRefresh($i);
    Next
    EndFunc ;==>_Paint_Bars_Procedure

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

    ; Internal Function, do not use !
    ; Author(s): Prog@ndy
    Func _Progress_CallBack_Init($ForceReInit = False)
    Local $sFuncName = "_Paint_Bars_Procedure", $iTime = 50, $sParam = "hwnd;int;int;dword"
    $_Progress_ahCallBack[2] += 1
    If $_Progress_ahCallBack[2] > 1 And Not $ForceReInit Then Return True
    If $ForceReInit Then
    Local $temp = $_Progress_ahCallBack[2]
    _Progress_CallBack_Free(1)
    $_Progress_ahCallBack[2] = $temp
    EndIf
    Local $hCallBack = DllCallbackRegister("_Paint_Bars_Procedure", "int", $sParam)

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

    Local $aTimer = DllCall("user32.dll", "uint", "SetTimer", _
    "hwnd", 0, "uint", 0, "int", $iTime, "ptr", DllCallbackGetPtr($hCallBack))

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

    $_Progress_ahCallBack[0] = $hCallBack
    $_Progress_ahCallBack[1] = $aTimer[0]

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

    Return True
    EndFunc ;==>_Progress_CallBack_Init

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

    ; Internal Function, do not use !
    ; Author(s): Prog@ndy
    Func _Progress_CallBack_Free($Force = False)
    $_Progress_ahCallBack[2] -= 1
    If $_Progress_ahCallBack[2] < 0 Then
    $_Progress_ahCallBack = 0
    Return
    EndIf
    If (Not $Force) And ($_Progress_ahCallBack[2] > 0) Then Return
    If $_Progress_ahCallBack[0] <> -1 Then DllCallbackFree($_Progress_ahCallBack[0])
    If $_Progress_ahCallBack[1] <> -1 Then DllCall("user32.dll", "int", "KillTimer", "hwnd", 0*ConsoleWrite("KILL" & @CRLF) , "uint", $_Progress_ahCallBack[1])
    $_Progress_ahCallBack[0] = -1
    $_Progress_ahCallBack[1] = -1
    $_Progress_ahCallBack[2] = 0
    EndFunc ;==>_Progress_CallBack_Free

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

    ;~ Func _DebugPrint($s_text)
    ;~ $s_text = StringReplace($s_text, @LF, @LF & "-")
    ;~ ConsoleWrite($s_text & @LF); & _
    ;~ EndFunc ;==>_DebugPrint

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

    Func __CheckForGDIPlus($Fatal = True)
    Local $x = DllOpen("GDIPlus.dll")
    Local $ret = DllCall("Kernel32.dll", "dword", "GetModuleHandle", "str", "GDIPlus")
    DllClose($x)
    If $ret[0] = 0 And $Fatal Then _WinAPI_FatalAppExit("GDIplus not found. Please install GDIplus to use this application")
    Return ($ret[0] = 0)
    EndFunc ;==>__CheckForGDIPlus

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

    #EndRegion Internal
    ;-------------------------------------------------------------------

    [/autoit]

    Sobald das Tool einmal gestartet wurde und die Progresse erstellt wurden, bekomme ich den Absturz, wenn ich das Programm schließe. Der Fehler kommt, sobald ich auch nur einmal die Funktion _ProgressCreate anwende...

    Ich weise daraufhin, dass dieses Tool kein Bot ist oder in irgendeiner Weise gegen die AGB von anderen Programmen verstößt.

    Einmal editiert, zuletzt von NoName (24. Februar 2009 um 23:13)