script reagiert nicht

  • HI
    Mein script reagiert irgendwie nicht.
    Wenn ich eine Messagebox einbaue dann macht er wieder was ich will.
    Aber ich will keine messagebox drinnen haben, warum reagiert der script nicht?
    Hier der Code:

    Spoiler anzeigen
    [autoit]

    #include <FTPEx.au3>
    #include <GDIPlus.au3>
    #Include <ScreenCapture.au3>
    $server = 'server'
    $username = 'id'
    $pass = 'pw'

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

    $Open = _FTP_Open('Mein FTP-Control')
    $Conn = _FTP_Connect($Open, $server, $username, $pass)
    while 1
    FileDelete ("bild.jpg")

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

    _ScreenCapture_Capture("bild.jpg") ;bild machen
    _GDIPlus_Startup()

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

    $oFile = @ScriptDir & "\bild.jpg" ;Pfade anpassen
    $nFile = @ScriptDir & "\bild1,jpg"

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

    Local $aDT = FileGetTime($oFile, 1, 0)
    $sInfo = $aDT[0] & "/" & $aDT[1] & "/" & $aDT[2] & " " & $aDT[3] & ":" & $aDT[4] & ":" & $aDT[5]
    ConsoleWrite($sInfo & @CRLF)

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

    $himg = _GDIPlus_ImageLoadFromFile($oFile)

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

    $hGraphics = _GDIPlus_ImageGetGraphicsContext($himg)

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

    $iX = _GDIPlus_ImageGetWidth($himg)
    $iy = _GDIPlus_ImageGetHeight($himg)
    $hBrush = _GDIPlus_BrushCreateSolid(); $Color)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 20, 2)
    $tLayout = _GDIPlus_RectFCreate($iX -220, $iY - 30)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sInfo, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $sInfo, $hFont, $aInfo[0], $hFormat, $hBrush)

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

    _GDIPlus_GraphicsDrawImage($hGraphics, $himg, 0, 0)
    _GDIPlus_ImageSaveToFile($himg, $nFile)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_ImageDispose($himg)
    _GDIPlus_Shutdown()
    _FTP_FilePut ($Conn,"dokument.txt","dokument.txt")
    _FTP_FilePut ($Conn,"bild1,jpg","bild.jpg")
    WEnd

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

    $Ftpc = _FTP_Close($Open)

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

    Einmal editiert, zuletzt von 93lucas (18. August 2010 um 20:12)

  • ein fortschritt bei 2 sekunden sleep macht er 2 mal screenshot und schläft für immer weiter.
    was soll ich machen?

  • du kannst

    [autoit]

    _GDIPlus_Startup()

    [/autoit]

    vor die Schleife setzen

    [autoit]

    _GDIPlus_Shutdown()

    [/autoit]

    nach der setzen. Dies könnte eventuell auch helfen. Kannst du mir bitte aber erklären, warum du laufend den aktuellen Bildschirm und ein Textdokument überträgst und dabei das vorherige überschreibst,

    mfg (Auto)Bert

  • Ich hab jetzt alles.
    Alles geht, bloß der script "frisst" so zu sagen meinen arbeitsspeicher.
    Wenn ich den script 5min lang laufen lasse, braucht er schon 100MB ram.
    Hier mal die endlosschleife vom script:

    Spoiler anzeigen
    [autoit]

    while 1
    DirCreate ("groß")
    DirCreate ("richtig")
    DirCreate ("kleiner")
    _ScreenCapture_Capture("groß\bild"&$zahl&".jpg") ;bild machen
    Sleep (750)
    $oFile = @ScriptDir & "\groß\bild"&$zahl&".jpg" ;Pfade anpassen
    $nFile = @ScriptDir & "\kleiner\bild"&$zahl&".jpg"

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

    Local $aDT = FileGetTime($oFile, 1, 0)
    $sInfo = $aDT[0] & "/" & $aDT[1] & "/" & $aDT[2] & " " & $aDT[3] & ":" & $aDT[4] & ":" & $aDT[5]
    ConsoleWrite($sInfo & @CRLF)

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

    $himg = _GDIPlus_ImageLoadFromFile($oFile)

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

    $hGraphics = _GDIPlus_ImageGetGraphicsContext($himg)

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

    $iX = _GDIPlus_ImageGetWidth($himg)
    $iy = _GDIPlus_ImageGetHeight($himg)
    $hBrush = _GDIPlus_BrushCreateSolid(); $Color)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 20, 2)
    $tLayout = _GDIPlus_RectFCreate($iX -220, $iY - 30)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sInfo, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $sInfo, $hFont, $aInfo[0], $hFormat, $hBrush)

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

    _GDIPlus_GraphicsDrawImage($hGraphics, $himg, 0, 0)
    _GDIPlus_ImageSaveToFile($himg, $nFile)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_ImageDispose($himg)
    Sleep (250)
    Local $NewImageWidth = 300
    Local $NewImageHeight = 200
    _ImageResize ("kleiner\bild"&$zahl&".jpg","richtig\bild"&$zahl&".jpg",$NewImageWidth, $NewImageHeight)
    FileDelete ("dokument2.txt")
    IniWrite ("dokument2.txt","1","1","")
    IniDelete ("dokument2.txt","1")
    $dokument2 = FileOpen ("dokument2.txt",1)
    FileWrite ($dokument2,$zahl)
    FileClose ($dokument2)
    _FTP_FilePut ($Conn,"dokument2.txt","dokument2.txt")
    _FTP_FilePut ($Conn,"richtig\1_bild"&$zahl&".jpg","/Bilder/bild"&$zahl&".jpg")
    DirRemove(@ScriptDir & "\groß", 1)
    DirRemove(@ScriptDir & "\kleiner", 1)
    $zahl += 1
    WEnd
    _GDIPlus_Shutdown()
    Func _ImageResize($sInImage, $sOutImage, $iW, $iH)
    Local $hWnd, $hDC, $hBMP, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0

    ;OutFile path, to use later on.
    Local $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))

    ;OutFile name, to use later on.
    Local $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1)

    ;OutFile extension , to use for the encoder later on.
    Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1))

    ; Win api to create blank bitmap at the width and height to put your resized image on.
    $hWnd = _WinAPI_GetDesktopWindow()
    $hDC = _WinAPI_GetDC($hWnd)
    $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH)
    _WinAPI_ReleaseDC($hWnd, $hDC)

    ;Start GDIPlus
    _GDIPlus_Startup()

    ;Get the handle of blank bitmap you created above as an image
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP)

    ;Load the image you want to resize.
    $hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)

    ;Get the graphic context of the blank bitmap
    $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1)

    ;Draw the loaded image onto the blank bitmap at the size you want
    _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH)

    ;Get the encoder of to save the resized image in the format you want.
    $CLSID = _GDIPlus_EncodersGetCLSID($Ext)

    ;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
    Do
    $i += 1
    Until (Not FileExists($sOP & $i & "_" & $sOF))

    ;Prefix the number to the begining of the output filename
    $sOutImage = $sOP & $i & "_" & $sOF

    ;Save the new resized image.
    _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID)

    ;Clean up and shutdown GDIPlus.
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _WinAPI_DeleteObject($hBMP)
    _GDIPlus_Shutdown()
    EndFunc

    [/autoit]


    Ja ich hab komische namen als ordner usw.

    Wie mach ich das, dass der nicht so viel ram(arbeitsspeicher) braucht?

    • Offizieller Beitrag

    Bitte poste eine ausführbares Beispiel. Dein Code kann man mangels Lauffähigkeit nicht testen und ggf. berichtigen.

  • Hier der Code mit denen 17 zeilen :

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #Include <ScreenCapture.au3>
    #include <FTPEx.au3>
    _GDIPlus_Startup()
    $zahl = 1
    $server = 'server'
    $username = 'ID'
    $pass = 'PW'
    DirRemove(@ScriptDir & "\groß", 1)
    DirRemove(@ScriptDir & "\kleiner", 1)
    DirRemove(@ScriptDir & "\richtig", 1)
    FileDelete ("dokument2.txt")
    IniWrite ("dokument2.txt","1","1","")
    IniDelete ("dokument2.txt","1")
    $Open = _FTP_Open('Mein FTP-Control')
    $Conn = _FTP_Connect($Open, $server, $username, $pass)
    _FTP_DirCreate($Conn,"Bilder")
    while 1
    DirCreate ("groß")
    DirCreate ("richtig")
    DirCreate ("kleiner")
    _ScreenCapture_Capture("groß\bild"&$zahl&".jpg") ;bild machen
    Sleep (750)
    $oFile = @ScriptDir & "\groß\bild"&$zahl&".jpg" ;Pfade anpassen
    $nFile = @ScriptDir & "\kleiner\bild"&$zahl&".jpg"

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

    Local $aDT = FileGetTime($oFile, 1, 0)
    $sInfo = $aDT[0] & "/" & $aDT[1] & "/" & $aDT[2] & " " & $aDT[3] & ":" & $aDT[4] & ":" & $aDT[5]
    ConsoleWrite($sInfo & @CRLF)

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

    $himg = _GDIPlus_ImageLoadFromFile($oFile)

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

    $hGraphics = _GDIPlus_ImageGetGraphicsContext($himg)

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

    $iX = _GDIPlus_ImageGetWidth($himg)
    $iy = _GDIPlus_ImageGetHeight($himg)
    $hBrush = _GDIPlus_BrushCreateSolid(); $Color)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 20, 2)
    $tLayout = _GDIPlus_RectFCreate($iX -220, $iY - 30)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sInfo, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $sInfo, $hFont, $aInfo[0], $hFormat, $hBrush)

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

    _GDIPlus_GraphicsDrawImage($hGraphics, $himg, 0, 0)
    _GDIPlus_ImageSaveToFile($himg, $nFile)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_ImageDispose($himg)
    Sleep (250)
    Local $NewImageWidth = 300
    Local $NewImageHeight = 200
    _ImageResize ("kleiner\bild"&$zahl&".jpg","richtig\bild"&$zahl&".jpg",$NewImageWidth, $NewImageHeight)
    FileDelete ("dokument2.txt")
    IniWrite ("dokument2.txt","1","1","")
    IniDelete ("dokument2.txt","1")
    $dokument2 = FileOpen ("dokument2.txt",1)
    FileWrite ($dokument2,$zahl)
    FileClose ($dokument2)
    _FTP_FilePut ($Conn,"dokument2.txt","dokument2.txt")
    _FTP_FilePut ($Conn,"richtig\1_bild"&$zahl&".jpg","/Bilder/bild"&$zahl&".jpg")
    DirRemove(@ScriptDir & "\groß", 1)
    DirRemove(@ScriptDir & "\kleiner", 1)
    $zahl += 1
    WEnd
    _GDIPlus_Shutdown()
    Func _ImageResize($sInImage, $sOutImage, $iW, $iH)
    Local $hWnd, $hDC, $hBMP, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0

    ;OutFile path, to use later on.
    Local $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))

    ;OutFile name, to use later on.
    Local $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1)

    ;OutFile extension , to use for the encoder later on.
    Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1))

    ; Win api to create blank bitmap at the width and height to put your resized image on.
    $hWnd = _WinAPI_GetDesktopWindow()
    $hDC = _WinAPI_GetDC($hWnd)
    $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH)
    _WinAPI_ReleaseDC($hWnd, $hDC)

    ;Start GDIPlus
    _GDIPlus_Startup()

    ;Get the handle of blank bitmap you created above as an image
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP)

    ;Load the image you want to resize.
    $hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)

    ;Get the graphic context of the blank bitmap
    $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1)

    ;Draw the loaded image onto the blank bitmap at the size you want
    _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH)

    ;Get the encoder of to save the resized image in the format you want.
    $CLSID = _GDIPlus_EncodersGetCLSID($Ext)

    ;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
    Do
    $i += 1
    Until (Not FileExists($sOP & $i & "_" & $sOF))

    ;Prefix the number to the begining of the output filename
    $sOutImage = $sOP & $i & "_" & $sOF

    ;Save the new resized image.
    _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID)

    ;Clean up and shutdown GDIPlus.
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _WinAPI_DeleteObject($hBMP)
    _GDIPlus_Shutdown()
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    Du mußt $hGraphics auch wieder freigeben, sonst hast du ein Speicherleck.

    Edit: _GDIPlus_Startup und _GDIPlus_Shutdown gehören nicht in die Funktion _ImageResize. Du rufst sie ja schon vor und nach der While Wend Schleife auf.

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #Include <ScreenCapture.au3>
    #include <FTPEx.au3>
    _GDIPlus_Startup()
    $zahl = 1
    $server = 'server'
    $username = 'ID'
    $pass = 'PW'
    DirRemove(@ScriptDir & "\groß", 1)
    DirRemove(@ScriptDir & "\kleiner", 1)
    DirRemove(@ScriptDir & "\richtig", 1)
    FileDelete ("dokument2.txt")
    IniWrite ("dokument2.txt","1","1","")
    IniDelete ("dokument2.txt","1")
    $Open = _FTP_Open('Mein FTP-Control')
    $Conn = _FTP_Connect($Open, $server, $username, $pass)
    _FTP_DirCreate($Conn,"Bilder")
    while 1
    DirCreate ("groß")
    DirCreate ("richtig")
    DirCreate ("kleiner")
    _ScreenCapture_Capture("groß\bild"&$zahl&".jpg") ;bild machen
    Sleep (750)
    $oFile = @ScriptDir & "\groß\bild"&$zahl&".jpg" ;Pfade anpassen
    $nFile = @ScriptDir & "\kleiner\bild"&$zahl&".jpg"

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

    Local $aDT = FileGetTime($oFile, 1, 0)
    $sInfo = $aDT[0] & "/" & $aDT[1] & "/" & $aDT[2] & " " & $aDT[3] & ":" & $aDT[4] & ":" & $aDT[5]
    ConsoleWrite($sInfo & @CRLF)

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

    $himg = _GDIPlus_ImageLoadFromFile($oFile)

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

    $hGraphics = _GDIPlus_ImageGetGraphicsContext($himg)

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

    $iX = _GDIPlus_ImageGetWidth($himg)
    $iy = _GDIPlus_ImageGetHeight($himg)
    $hBrush = _GDIPlus_BrushCreateSolid(); $Color)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 20, 2)
    $tLayout = _GDIPlus_RectFCreate($iX -220, $iY - 30)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sInfo, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, $sInfo, $hFont, $aInfo[0], $hFormat, $hBrush)

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

    _GDIPlus_GraphicsDrawImage($hGraphics, $himg, 0, 0)
    _GDIPlus_ImageSaveToFile($himg, $nFile)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_ImageDispose($himg)
    _GDIPlus_GraphicsDispose($hGraphics); $hGraphics muß auch wieder freigegeben werden.

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

    Sleep (250)
    Local $NewImageWidth = 300
    Local $NewImageHeight = 200
    _ImageResize ("kleiner\bild"&$zahl&".jpg","richtig\bild"&$zahl&".jpg",$NewImageWidth, $NewImageHeight)
    FileDelete ("dokument2.txt")
    IniWrite ("dokument2.txt","1","1","")
    IniDelete ("dokument2.txt","1")
    $dokument2 = FileOpen ("dokument2.txt",1)
    FileWrite ($dokument2,$zahl)
    FileClose ($dokument2)
    _FTP_FilePut ($Conn,"dokument2.txt","dokument2.txt")
    _FTP_FilePut ($Conn,"richtig\1_bild"&$zahl&".jpg","/Bilder/bild"&$zahl&".jpg")
    DirRemove(@ScriptDir & "\groß", 1)
    DirRemove(@ScriptDir & "\kleiner", 1)
    $zahl += 1
    WEnd
    _GDIPlus_Shutdown()
    Func _ImageResize($sInImage, $sOutImage, $iW, $iH)
    Local $hWnd, $hDC, $hBMP, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0

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

    ;OutFile path, to use later on.
    Local $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))

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

    ;OutFile name, to use later on.
    Local $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1)

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

    ;OutFile extension , to use for the encoder later on.
    Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1))

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

    ; Win api to create blank bitmap at the width and height to put your resized image on.
    $hWnd = _WinAPI_GetDesktopWindow()
    $hDC = _WinAPI_GetDC($hWnd)
    $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH)
    _WinAPI_ReleaseDC($hWnd, $hDC)

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

    ;Start GDIPlus
    ;~ _GDIPlus_Startup()

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

    ;Get the handle of blank bitmap you created above as an image
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP)

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

    ;Load the image you want to resize.
    $hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)

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

    ;Get the graphic context of the blank bitmap
    $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1)

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

    ;Draw the loaded image onto the blank bitmap at the size you want
    _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH)

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

    ;Get the encoder of to save the resized image in the format you want.
    $CLSID = _GDIPlus_EncodersGetCLSID($Ext)

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

    ;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
    Do
    $i += 1
    Until (Not FileExists($sOP & $i & "_" & $sOF))

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

    ;Prefix the number to the begining of the output filename
    $sOutImage = $sOP & $i & "_" & $sOF

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

    ;Save the new resized image.
    _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID)

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

    ;Clean up and shutdown GDIPlus.
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _WinAPI_DeleteObject($hBMP)
    ;~ _GDIPlus_Shutdown()
    EndFunc

    [/autoit]