2 Scripte zu einem machen

  • Hallo leute,
    ich habe mir 2 Scripte zusammengeschrieben, und würde sie gerne als ein Script aufführen

    als erstes der Countdown bei dem ich gute Hilfe hatte:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <Date.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <EditConstants.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <Misc.au3>
    #include <SliderConstants.au3>
    #include <StaticConstants.au3>
    #include <Timers.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

    Opt('MustDeclareVars', 1)
    Opt('GUIOnEventMode', 1)

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

    _GDIPlus_Startup()

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

    Global $iWidth = 400
    Global $iHeight = 300

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

    Global $days, $hour, $hour2, $Mins, $secs

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

    Global $iColor_BG = 0xFF00FF00
    Global $iColor_TextFill = 0xFF353535

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

    Global $iColor_TextFill2 = 0xFFFF0000
    Global $iColor_TextFill3 = 0xFF0000FF
    Global $iColor_TextFill4 = 0xFF353535
    Global $iColor_TextBorder = 0xFFA00000

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

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $hGUI = GUICreate("GDI+", $iWidth, $iHeight)
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    _GDIPlus_GraphicsClear($hGfxBuffer, $iColor_BG)

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

    Global $hPen = _GDIPlus_PenCreate($iColor_TextBorder, 3)
    DllCall($ghGDIPDll, "uint", "GdipSetPenLineJoin", "hwnd", $hPen, "int", 2)
    Global $hBrush = _GDIPlus_BrushCreateSolid($iColor_TextFill)
    Global $day, $hour, $hour2, $Mins, $secs
    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

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

    GUISetState()

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

    Global $hMatrix = _GDIPlus_MatrixCreate()
    Global $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
    Global $hFormat = _GDIPlus_StringFormatCreate()
    Global $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Global $hPath = _CreatePath("88 - 88:88:88")

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

    Global $sText, $sTextOld
    Global $fStep = 0

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

    While 1
    GUISetCursor(16, 1, $hGUI)
    _TicksToTime(_DateDiff('s', _NowCalc(), "2013/01/01 00:00:00") * 1000, $hour, $Mins, $secs)
    If $hour >23 Then
    $days = StringFormat("%02i", $hour / 24); volle Tage
    $hour = $hour - ($days*24); volle Tage abziehen
    Else
    $days = 0
    EndIf

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

    If $sText = "00 - 00:00:00" Then
    ; Funktion des 2.Scriptes soll dann ausgeführt werden
    Else

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

    $sText = StringFormat("%02i - %02i:%02i:%02i", $days, $hour, $Mins, $secs)
    EndIf

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

    If $sText <> $sTextOld Then
    $sTextOld = $sText
    DllCall($ghGDIPDll, "uint", "GdipResetPath", "hwnd", $hPath)
    DllCall($ghGDIPDll, "uint", "GdipAddPathString", "hwnd", $hPath, "wstr", $sText, "int", -1, "hwnd", $hFamily, "int", 1, "float", 100, "ptr", DllStructGetPtr($tLayout), "hwnd", $hFormat)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)
    EndIf

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

    $fStep += 0.01
    _Draw(Abs(Sin($fStep)))
    Sleep(10)
    WEnd

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

    Func _Draw($fScale)
    _GDIPlus_GraphicsClear($hGfxBuffer, $iColor_BG)

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

    DllCall($ghGDIPDll, "uint", "GdipTranslateWorldTransform", "hwnd", $hGfxBuffer, "float", -$iWidth / 2, "float", -$iHeight / 2, "int", False)
    DllCall($ghGDIPDll, "uint", "GdipScaleWorldTransform", "hwnd", $hGfxBuffer, "float", $fScale, "float", $fScale, "int", True)
    DllCall($ghGDIPDll, "uint", "GdipTranslateWorldTransform", "hwnd", $hGfxBuffer, "float", $iWidth / 2, "float", $iHeight / 2, "int", True)

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

    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen, "hwnd", $hPath)
    DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hGfxBuffer, "hwnd", $hBrush, "hwnd", $hPath)

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

    DllCall($ghGDIPDll, "uint", "GdipResetWorldTransform", "hwnd", $hGfxBuffer)

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

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    EndFunc ;==>_Draw

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

    Func _CreatePath($sText)

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

    Local $tBounds = _GDIPlus_RectFCreate(0, 0, 0, 0)

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

    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 1, False)
    Local $hPath = $aResult[2]

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

    DllCall($ghGDIPDll, "uint", "GdipAddPathString", "hwnd", $hPath, "wstr", $sText, "int", -1, "hwnd", $hFamily, "int", 1, "float", 100, "ptr", DllStructGetPtr($tLayout), "hwnd", $hFormat)
    DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", DllStructGetPtr($tBounds), "hwnd", 0, "hwnd", 0)

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

    _GDIPlus_MatrixTranslate($hMatrix, -DllStructGetData($tBounds, "X"), -DllStructGetData($tBounds, "Y"))
    _GDIPlus_MatrixScale($hMatrix, $iWidth / DllStructGetData($tBounds, "Width"), $iHeight / DllStructGetData($tBounds, "Height"), True)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)

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

    Return $hPath
    EndFunc ;==>_CreatePath

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

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

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

    Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return True
    EndFunc ;==>WM_ERASEBKGND

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

    Func _Exit()
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc

    [/autoit]

    So und wenn der Countdown dann auf 00 - 00:00:00 ist dann soll das hier kommen

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>

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

    _GDIPlus_Startup()
    OnAutoItExitRegister("OnExit")
    Dim $iCount = 10, $iExplosion = 100, $iExplosionGround = 1, $iRadius = 600, $iBack = 0x09000000, $iSleep = 5
    Global $iWidth = @DesktopWidth, $iHeight = @DesktopHeight, $aStart[$iCount][4] = [[Random(0, $iWidth, 0), Random(0, $iHeight, 0), 0, _GDIPlus_PenCreate(Random(0xFF000000, 0xFFFFFFFF, 0))],[Random(0, $iWidth, 0), Random(0, $iHeight, 0), 0, _GDIPlus_PenCreate(Random(0xFF000000, 0xFFFFFFFF, 0))]], $iSleeping = 0
    For $i = 0 To UBound($aStart) - 1
    $aStart[$i][0] = Random(0, $iWidth, 0)
    $aStart[$i][1] = Random(0, $iHeight, 0)
    $aStart[$i][2] = $iExplosion
    $aStart[$i][3] = _GDIPlus_PenCreate(Random(0xFF000000, 0xFFFFFFFF, 0))
    Next

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

    $hGUI = GUICreate("", $iWidth, $iHeight, 0, 0, -2147483648)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphic)
    $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsClear($hBackbuffer, 0xFF000000)

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

    GUIRegisterMsg(15, "WM_PAINT")

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

    GUISetState(@SW_SHOW, $hGUI)

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

    While GUIGetMsg() <> -3
    _GDIPlus_GraphicsClear($hBackbuffer, $iBack)
    If $iSleeping = 0 Then
    For $j = 0 To UBound($aStart) - 1
    For $i = 0 To 35
    $aDraw = Dreieck($i * 10, $aStart[$j][2] - $iExplosion)
    _GDIPlus_GraphicsDrawRect($hBackbuffer, $aStart[$j][0] + Round($aDraw[0], 0), $aStart[$j][1] + Round($aDraw[1], 0), 2, 2, $aStart[$j][3])
    Next
    $aStart[$j][2] += $iExplosionGround + Ceiling(10 * $iExplosion / ($aStart[$j][2]))
    If $aStart[$j][2] > $iRadius Then
    $iSleeping = $iSleep
    $aStart[$j][0] = Random(0, $iWidth, 0)
    $aStart[$j][1] = Random(0, $iHeight, 0)
    $aStart[$j][2] = $iExplosion
    _GDIPlus_PenDispose($aStart[$j][3])
    $aStart[$j][3] = _GDIPlus_PenCreate(Random(0xFF000000, 0xFFFFFFFF, 0))
    EndIf
    Next
    Else
    $iSleeping -= 1
    EndIf
    _WinAPI_RedrawWindow($hGUI, 0, 0, 2)
    WEnd

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

    Func WM_PAINT()
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)
    EndFunc ;==>WM_PAINT

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

    Func OnExit()
    For $i = 0 To UBound($aStart) - 1
    _GDIPlus_PenDispose($aStart[$i][3])
    Next
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    EndFunc ;==>OnExit

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

    Func Dreieck($iWinkel, $iLaenge)
    Local $iDeg = 0.0174532925199433, $aRet[2]
    $aRet[0] = Sin($iWinkel * $iDeg) * $iLaenge
    $aRet[1] = Cos($iWinkel * $iDeg) * $iLaenge
    Return $aRet
    EndFunc ;==>Dreieck

    [/autoit]

    Das ganze hätte ich aber gerne in einem Script, habe es selbst schn versucht aber da gibts dann immerwieder Fehler die ich dann nicht nachvollziehen kann,
    kann mir jemand helfen?

    LG
    Ququknife

  • das problem ist, ich will das erste script auch noch auf vollbild laufen lassen, und wenn ich dann angebe dass das zweite script gestartet wird, wenn der Counter abgelaufen ist, sieht man noch den desktop für ne sekunde oder so und das will ich so nicht haben deswegen möchte ich es in einem Script haben!!

  • jetzt habs ich gecheckt mit umschreiben :) alles was ich machen musste die Variablen auf die Variablen für das komplette Script anpassen und die Globalen Variablen des 2.Scriptes einfach als Lokale Variablen in die Func Schleife mit reinschreiben. Jetzt Funktioniert es super :)

    @Make-Grafik
    Vielen Dank für deinen Tipp mit "in eine Funktion reinpacken" :)