Beiträge von TheLuBu
-
-
So ein Fall ist eingetreten, den ich nicht bedacht habe
[autoit]
Wenn $a_AArr[0] 2 ist, also nurnoch 2 Zeichen fehlen, dann kommt der ErrorIf $i < 3 and $a_AArr[0] > 2 Then
[/autoit]
If $a_AArr[$i] = "0" And $a_AArr[$i + 1] = "x" Then ContinueLoop
If $a_AArr[$i] = "x" And $a_AArr[$i - 1] = "0" Then ContinueLoop
EndIfDas sollte jetzt aber helfen.
Ich bin jetzt bis Montag nicht mehr am PC, wenn noch was ist melde ich mich Montag
-
ok, zu dem Out of Range Error ersetz mal das alte hiermit
[autoit]If $i < 3 Then
[/autoit]
If $a_AArr[$i] = "0" And $a_AArr[$i + 1] = "x" Then ContinueLoop
If $a_AArr[$i] = "x" And $a_AArr[$i - 1] = "0" Then ContinueLoop
EndIfIch lasse es grade bei mir nochmal durchlaufen und schaue, ob der das bei mir Speichert
Wenn du -1 eingibtst, lässt der ein Zeichen uas, also nimm das wieder raus

--EDIT--
Achja, ich hatte den Pfad bei _Decode verändert, wo er das speichert, kann es sein das die Datei nur woanders liegt?--EDIT2--
Zu den Zip Dateien: Ich benutze diese UDFSpoiler anzeigen
[autoit];#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
[/autoit] [autoit][/autoit] [autoit]
#include <array.au3>
; ------------------------------------------------------------------------------
;
; AutoIt Version: 3.2
; Language: English
; Description: ZIP Functions.
; Author: torels_
;
; ------------------------------------------------------------------------------;~ If UBound($CMDLine) > 1 Then
[/autoit] [autoit][/autoit] [autoit]
;~ If $CMDLine[1] <> "" Then _Zip_VirtualZipOpen()
;~ EndIf;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_Create()
; Description: Create Empty ZIP file.
; Parameter(s): $hFilename - Complete path to zip file that will be created
; Requirement(s): none.
; Return Value(s): Returns the Zip file path (to be used as a handle - even though it's not necessary)
; Author(s): torels_
;
;===============================================================================
Func _Zip_Create($hFilename)
$hFp = FileOpen($hFilename, 26)
$sString = Chr(80) & Chr(75) & Chr(5) & Chr(6) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0) & Chr(0)
FileWrite($hFp, $sString)
If @error Then Return SetError(1,0,0)
FileClose($hFp)While Not FileExists($hFilename)
[/autoit] [autoit][/autoit] [autoit]
Sleep(10)
Wend
Return $hFilename
EndFunc ;==>_Zip_Create;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_AddFile()
; Description: Add a file to a ZIP Archieve.
; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)
; $hFile2Add - Complete path to the file that will be added
; $flag = 1
; - 0 ProgressBox
; - 1 no progress box
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - sets @error 1~3
; @error = 1 no Zip file
; @error = 2 no dll
; @error = 3 dll isn't registered
; On Failure - Returns False
; Author(s): torels_
; Notes: The return values will be given once the compressing process is ultimated... it takes some time with big files
;
;===============================================================================
Func _Zip_AddFile($hZipFile, $hFile2Add, $flag = 1)
Local $DLLChk = _Zip_DllChk()
Local $files = _Zip_Count($hZipFile)
If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll
If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file
$oApp = ObjCreate("Shell.Application")
$copy = $oApp.NameSpace($hZipFile).CopyHere($hFile2Add)
While 1
If $flag = 1 then _Hide()
If _Zip_Count($hZipFile) = ($files+1) Then ExitLoop
Sleep(10)
WEnd
Return SetError(0,0,1)
EndFunc ;==>_Zip_AddFile;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_AddFolder()
; Description: Add a folder to a ZIP Archieve.
; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)
; $hFolder - Complete path to the folder that will be added (possibly including "\" at the end)
; $flag = 1
; - 1 no progress box
; - 0 progress box
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - sets @error 1~3
; @error = 1 no Zip file
; @error = 2 no dll
; @error = 3 dll isn't registered
; Author(s): torels_
; Notes: The return values will be given once the compressing process is ultimated... it takes some time with big files
;
;===============================================================================
Func _Zip_AddFolder($hZipFile, $hFolder, $flag = 1)
Local $DLLChk = _Zip_DllChk()
If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll
If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file
If StringRight($hFolder, 1) <> "\" Then $hFolder &= "\"
$files = _Zip_Count($hZipFile)
$oApp = ObjCreate("Shell.Application")
$oCopy = $oApp.NameSpace($hZipFile).CopyHere($oApp.Namespace($hFolder))
While 1
If $flag = 1 then _Hide()
If _Zip_Count($hZipFile) = ($files+1) Then ExitLoop
Sleep(10)
WEnd
Return SetError(0,0,1)
EndFunc ;==>_Zip_AddFolder;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_AddFolderContents()
; Description: Add a folder to a ZIP Archieve.
; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)
; $hFolder - Complete path to the folder that will be added (possibly including "\" at the end)
; $flag = 1
; - 1 no progress box
; - 0 progress box
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - sets @error 1~3
; @error = 1 no Zip file
; @error = 2 no dll
; @error = 3 dll isn't registered
; Author(s): torels_
; Notes: The return values will be given once the compressing process is ultimated... it takes some time with big files
;
;===============================================================================
Func _Zip_AddFolderContents($hZipFile, $hFolder, $flag = 1)
Local $DLLChk = _Zip_DllChk()
If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll
If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file
If StringRight($hFolder, 1) <> "\" Then $hFolder &= "\"
$files = _Zip_Count($hZipFile)
$oApp = ObjCreate("Shell.Application")
$oFolder = $oApp.NameSpace($hFolder)
$oCopy = $oApp.NameSpace($hZipFile).CopyHere($oFolder.Items)
$oFC = $oApp.NameSpace($hFolder).items.count
While 1
If $flag = 1 then _Hide()
If _Zip_Count($hZipFile) = ($files+$oFC) Then ExitLoop
Sleep(10)
WEnd
Return SetError(0,0,1)
EndFunc ;==>_Zip_AddFolderContents;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_Delete()
; Description: Delete a file from a ZIP Archive.
; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)
; $hFolder - Complete path to the folder that will be added (possibly including "\" at the end)
; $flag = 1
; - 1 no progress box
; - 0 progress box
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - sets @error 1~3
; @error = 1 no Zip file
; @error = 2 no dll
; @error = 3 dll isn't registered
; Author(s): torels_
; Notes: none
;
;===============================================================================
Func _Zip_Delete($hZipFile, $hFilename, $flag = 1)
Local $DLLChk = _Zip_DllChk()
If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll
If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file
$list = _Zip_List($hZipFile)
$dir = @TempDir & "\tmp" & Floor(Random(0,100))
For $i = 1 to $list[0]
If $list[$i] <> $hFilename Then _Zip_Unzip($hZipFile,$list[$i],$dir, $flag)
Next
FileDelete($hZipFile)
_Zip_Create($hZipFile)
_Zip_AddFolderContents($hZipFile, $dir, $flag)
DirRemove($dir)
EndFunc;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_UnzipAll()
; Description: Extract all files contained in a ZIP Archieve.
; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)
; $hDestPath - Complete path to where the files will be extracted
; $flag = 1
; - 1 no progress box
; - 0 progress box
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - sets @error 1~3
; @error = 1 no Zip file
; @error = 2 no dll
; @error = 3 dll isn't registered
; Author(s): torels_
; Notes: The return values will be given once the extracting process is ultimated... it takes some time with big files
;
;===============================================================================
Func _Zip_UnzipAll($hZipFile, $hDestPath, $flag = 1)
Local $DLLChk = _Zip_DllChk()
If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll
If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
If Not FileExists($hZipFile) Then Return SetError(2, 0, 0) ;no zip file
If Not FileExists($hDestPath) Then DirCreate($hDestPath)
Local $aArray[1]
$oApp = ObjCreate("Shell.Application")
$oApp.Namespace($hDestPath).CopyHere($oApp.Namespace($hZipFile).Items)
For $item In $oApp.Namespace($hZipFile).Items
_ArrayAdd($aArray, $item)
Next
While 1
If $flag = 1 then _Hide()
If FileExists($hDestPath & "\" & $aArray[UBound($aArray) - 1]) Then
Return SetError(0, 0, 1)
ExitLoop
EndIf
Sleep(500)
WEnd
EndFunc ;==>_Zip_UnzipAll;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_Unzip()
; Description: Extract a single file contained in a ZIP Archieve.
; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)
; $hFilename - Name of the element in the zip archive ex. "hello_world.txt"
; $hDestPath - Complete path to where the files will be extracted
; $flag = 1
; - 1 no progress box
; - 0 progress box
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - sets @error 1~3
; @error = 1 no Zip file
; @error = 2 no dll
; @error = 3 dll isn't registered
; Author(s): torels_
; Notes: The return values will be given once the extracting process is ultimated... it takes some time with big files
;
;===============================================================================
Func _Zip_Unzip($hZipFile, $hFilename, $hDestPath, $flag = 1)
Local $DLLChk = _Zip_DllChk()
If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll
If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file
If Not FileExists($hDestPath) Then DirCreate($hDestPath)
$oApp = ObjCreate("Shell.Application")
$hFolderitem = $oApp.NameSpace($hZipFile).Parsename($hFilename)
$oApp.NameSpace($hDestPath).Copyhere($hFolderitem)
While 1
If $flag = 1 then _Hide()
If FileExists($hDestPath & "\" & $hFilename) Then
return SetError(0, 0, 1)
ExitLoop
EndIf
Sleep(500)
WEnd
EndFunc ;==>_Zip_Unzip;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_Count()
; Description: Count files contained in a ZIP Archieve.
; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - sets @error 1~3
; @error = 1 no Zip file
; @error = 2 no dll
; @error = 3 dll isn't registered
; Author(s): torels_
;
;===============================================================================
Func _Zip_Count($hZipFile)
Local $DLLChk = _Zip_DllChk()
If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll
If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file
$items = _Zip_List($hZipFile)
Return UBound($items) - 1
EndFunc ;==>_Zip_Count;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_CountAll()
; Description: Count All files contained in a ZIP Archive (including Sub Directories)
; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - sets @error 1~3
; @error = 1 no Zip file
; @error = 2 no dll
; @error = 3 dll isn't registered
; Author(s): torels_, Smashly
;
;===============================================================================
Func _Zip_CountAll($hZipFile)
Local $DLLChk = _Zip_DllChk()
If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll
If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file
$oApp = ObjCreate("Shell.Application")
$oDir = $oApp.NameSpace(StringLeft($hZipFile, StringInStr($hZipFile, "\", 0, -1)))
$sZipInf = $oDir.GetDetailsOf($oDir.ParseName(StringTrimLeft($hZipFile, StringInStr($hZipFile, "\", 0, -1))), -1)
Return StringRight($sZipInf, StringLen($sZipInf) - StringInStr($sZipInf, ": ") - 1)
EndFunc;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_List()
; Description: Returns an Array containing of all the files contained in a ZIP Archieve.
; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - sets @error 1~3
; @error = 1 no Zip file
; @error = 2 no dll
; @error = 3 dll isn't registered
; Author(s): torels_
;
;===============================================================================
Func _Zip_List($hZipFile)
local $aArray[1]
Local $DLLChk = _Zip_DllChk()
If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll
If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file
$oApp = ObjCreate("Shell.Application")
$hList = $oApp.Namespace($hZipFile).Items
For $item in $hList
_ArrayAdd($aArray,$item.name)
Next
$aArray[0] = UBound($aArray) - 1
Return $aArray
EndFunc ;==>_Zip_List;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_Search()
; Description: Search files in a ZIP Archive.
; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)
; $sSearchString - name of the file to be searched
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - sets @error 1 (no file found)
; Author(s): torels_
; Notes: none
;
;===============================================================================
Func _Zip_Search($hZipFile, $sSearchString)
local $aArray
Local $DLLChk = _Zip_DllChk()
If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0) ;no dll
If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
If Not FileExists($hZipFile) Then Return SetError(1, 0, 0) ;no zip file
$list = _Zip_List($hZipFile)
for $i = 0 to UBound($list) - 1
if StringInStr($list[$i],$sSearchstring) > 0 Then
_ArrayAdd($aArray, $list[$i])
EndIf
Next
if UBound($aArray) - 1 = 0 Then
Return SetError(1,0,0)
Else
Return $aArray
EndIf
EndFunc ;==> _Zip_Search;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_SearchInFile()
; Description: Search files in a ZIP Archive's File.
; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)
; $sSearchString - name of the file to be searched
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - sets @error 1 (no file found)
; Author(s): torels_
; Notes: none
;
;===============================================================================
Func _Zip_SearchInFile($hZipFile, $sSearchString)
local $aArray
$list = _Zip_List($hZipFile)
for $i = 1 to UBound($list) - 1
_Zip_Unzip($hZipFile, $list[$i], @TempDir & "\tmp_zip.file")
$read = FileRead(@TempDir & "\tmp_zip.file")
if StringInStr($read,$sSearchstring) > 0 Then
_ArrayAdd($aArray, $list[$i])
EndIf
Next
if UBound($aArray) - 1 = 0 Then
Return SetError(1,0,1)
Else
Return $aArray
EndIf
EndFunc ;==> _Zip_Search;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_VirtualZipCreate()
; Description: Create a Virtual Zip.
; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)
; $sPath - Path to where create the Virtual Zip
; Requirement(s): none.
; Return Value(s): On Success - List of Created Files
; On Failure - sets @error 1~3
; @error = 1 no Zip file
; @error = 2 no dll
; @error = 3 dll isn't registered
; Author(s): torels_
; Notes: none
;
;===============================================================================
Func _Zip_VirtualZipCreate($hZipFile, $sPath)
$List = _Zip_List($hZipFile)
If @error Then Return SetError(@error,0,0)
If Not FileExists($sPath) Then DirCreate($sPath)
If StringRight($sPath, 1) = "\" Then $sPath = StringLeft($sPath, StringLen($sPath) -1)
For $i = 1 to $List[0]
If Not @Compiled Then
$Cmd = @AutoItExe
$params = '"' & @ScriptFullPath & '" ' & '"' & $hZipFile & "," & $List[$i] & '"'
Else
$Cmd = @ScriptFullPath
$Params = '"' & $hZipFile & "," & $List[$i] & '"'
EndIf
FileCreateShortcut($Cmd, $sPath & "\" & $List[$i], -1,$Params, "Virtual Zipped File", _GetIcon($List[$i], 0), "", _GetIcon($List[$i], 1))
Next
$List = _ArrayInsert($List, 1, $sPath)
Return $List
EndFunc;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_VirtualZipOpen()
; Description: Open A File in a Virtual Zip, Internal Function.
; Parameter(s): none.
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - sets @error 1~3
; @error = 1 no Zip file
; @error = 2 no dll
; @error = 3 dll isn't registered
; Author(s): torels_
; Notes: none
;
;===============================================================================
Func _Zip_VirtualZipOpen()
$ZipSplit = StringSplit($CMDLine[1], ",")
$ZipName = $ZipSplit[1]
$ZipFile = $ZipSplit[2]
_Zip_Unzip($ZipName, $ZipFile, @TempDir & "\", 4+16) ;no progress + yes to all
If @error Then Return SetError(@error,0,0)
ShellExecute(@TempDir & "\" & $ZipFile)
EndFunc;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_VirtualZipOpen()
; Description: Delete a Virtual Zip.
; Parameter(s): none.
; Requirement(s): none.
; Return Value(s): On Success - 0
; On Failure - none.
; Author(s): torels_
; Notes: none
;
;===============================================================================
Func _Zip_VirtualZipDelete($aVirtualZipHandle)
For $i = 2 to UBound($aVirtualZipHandle)-1
If FileExists($aVirtualZipHandle[1] & "\" & $aVirtualZipHandle[$i]) Then FileDelete($aVirtualZipHandle[1] & "\" & $aVirtualZipHandle[$i])
Next
Return 0
EndFunc;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _Zip_DllChk()
; Description: Internal error handler.
; Parameter(s): none.
; Requirement(s): none.
; Return Value(s): Failure - @extended = 1
; Author(s): smashley
;
;===============================================================================
Func _Zip_DllChk()
If Not FileExists(@SystemDir & "\zipfldr.dll") Then Return 2
If Not RegRead("HKEY_CLASSES_ROOT\CLSID\{E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31}", "") Then Return 3
Return 0
EndFunc ;==>_Zip_DllChk;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _GetIcon()
; Description: Internal Function.
; Parameter(s): $file - File form which to retrieve the icon
; $ReturnType - IconFile or IconID
; Requirement(s): none.
; Return Value(s): Icon Path/ID
; Author(s): torels_
;
;===============================================================================
Func _GetIcon($file, $ReturnType = 0)
$FileType = StringSplit($file, ".")
$FileType = $FileType[UBound($FileType)-1]
$FileParam = RegRead("HKEY_CLASSES_ROOT\." & $FileType, "")
$DefaultIcon = RegRead("HKEY_CLASSES_ROOT\" & $FileParam & "\DefaultIcon", "")If Not @error Then
[/autoit] [autoit][/autoit] [autoit]
$IconSplit = StringSplit($DefaultIcon, ",")
ReDim $IconSplit[3]
$Iconfile = $IconSplit[1]
$IconID = $IconSplit[2]
Else
$Iconfile = @SystemDir & "\shell32.dll"
$IconID = -219
EndIfIf $ReturnType = 0 Then
[/autoit] [autoit][/autoit] [autoit]
Return $Iconfile
Else
Return $IconID
EndIf
EndFunc;===============================================================================
[/autoit] [autoit][/autoit] [autoit]
;
; Function Name: _IsFullPath()
; Description: Internal Function.
; Parameter(s): $path - a zip path
; Requirement(s): none.
; Return Value(s): success - True.
; failure - False.
; Author(s): torels_
;
;===============================================================================
Func _IsFullPath($path)
if StringInStr($path,":\") then
Return True
Else
Return False
EndIf
Endfunc;===============================================================================
[/autoit]
;
; Function Name: _Hide()
; Description: Internal Function.
; Parameter(s): none
; Requirement(s): none.
; Return Value(s): none.
; Author(s): torels_
;
;===============================================================================
Func _Hide()
If ControlGetHandle("[CLASS:#32770]", "", "[CLASS:SysAnimate32; INSTANCE:1]") <> "" And WinGetState("[CLASS:#32770]") <> @SW_HIDE Then ;The Window Exists
$hWnd = WinGetHandle("[CLASS:#32770]")
WinSetState($hWnd, "", @SW_HIDE)
EndIf
EndFunc
Vielleicht reicht es ja -
-
-
es muss an einem String liegen, der größer ist als die Begrenzung.
Ich denke, das du mehr als ~85MB freien Ram hast
Ändere mal die Zahl 2147483646 an allen Stellen in 2147473646, dann trennt er 10000 Zeichen früher, vielleicht reicht das--EDIT-- Achja, lass dir das Ergebnisarray nicht anzeigen, der lädt sich tot, weil es relativ groß ist
--EDIT2-- Ich habe grade nochmal getestet, bei mir hat Autoit beim durchlauf eine Auslastung von bis zu 4500MB RAM, ist wohl doch ein bisschen Viel rechnerei mit vielen großen Daten.Vielleicht wäre es einfacher, die Daten nicht zu Speichern, sondern direkt in eine Datei zu schreiben, ich schau mal ob es damit besser klappt
--Edit3-- Probier es mal damit
Spoiler anzeigen
[autoit]Func _Decodefile($s_FileName)
[/autoit]
Local $a_AArr, $s_Mid, $read, $s_ret, $i_done, $len, $count, $exitdo = 0, $maxstringlenght = 2147483646, $pos = 0
$hFile = FileOpen($s_FileName, 16)
$hFile2 = FileOpen(@ScriptDir & "\extracted-vfiles\test-decoded.v", 17)
FileWrite($hFile2, "0x")
Do
$read = FileRead($hFile, $maxstringlenght)
$len = StringLen($read)
If $len < $maxstringlenght Then
$exitdo = 1
Else
If $pos = 0 Then
FileSetPos($hFile, $pos + 1, 0)
Else
FileSetPos($hFile, $pos, 0)
EndIf
$pos += $maxstringlenght
EndIf
$i_done = 1
$count = Ceiling($len / 16777215)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $len = ' & $len & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $count = ' & $count & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
For $k = 1 To $count
$s_ret = ""
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $k = ' & $k & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$s_Mid = StringMid($read, $i_done, 16777215)
$a_AArr = StringSplit($s_Mid, "")
For $i = 1 To $a_AArr[0]
If IsInt($i/100000) Then ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $i = ' & $i & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
If $a_AArr[$i] = "0" And $a_AArr[$i + 1] = "x" Then ContinueLoop
If $a_AArr[$i] = "x" And $a_AArr[$i - 1] = "0" Then ContinueLoop
Switch $a_AArr[$i]
Case "5"
$s_ret &= "0"
Case "4"
$s_ret &= "1"
Case "7"
$s_ret &= "2"
Case "6"
$s_ret &= "3"
Case "1"
$s_ret &= "4"
Case "0"
$s_ret &= "5"
Case "3"
$s_ret &= "6"
Case "2"
$s_ret &= "7"
Case "D"
$s_ret &= "8"
Case "C"
$s_ret &= "9"
Case "F"
$s_ret &= "A"
Case "E"
$s_ret &= "B"
Case "9"
$s_ret &= "C"
Case "8"
$s_ret &= "D"
Case "B"
$s_ret &= "E"
Case "A"
$s_ret &= "F"
EndSwitch
Next
$i_done += 16777215
$t = FileWrite($hFile2, $s_ret)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $t = ' & $t & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
Next
Until $exitdo = 1
FileClose($hFile)
FileClose($hFile2)
Return 1
EndFunc ;==>_Decodefile -
Ich hab das mal geändert, für den Fall, das du auch größere Dateien einlesen willst, das hier sollte dann auch klappen.
Der Rückgabetyp ist jetzt aber ein Array, kannst du aber nacheinander in eine Datei schreiben.Spoiler anzeigen
[autoit]Func _Decodefile($s_FileName)
[/autoit]
Local $a_AArr, $s_Mid, $read, $s_ret, $i_done, $len, $count, $exitdo = 0, $ret_array[1], $maxstringlenght = 2147483646, $pos = 0
$hFile = FileOpen($s_FileName, 16)
Do
$read = FileRead($hFile, $maxstringlenght)
$len = StringLen($read)
If $len < 2147483646 Then
$exitdo = 1
Else
If $pos = 0 Then
FileSetPos($hFile, $pos + 1, 0)
Else
FileSetPos($hFile, $pos, 0)
EndIf
$pos += 2147483646
EndIf
$i_done = 1
$s_ret = ""
$count = Ceiling($len / 16777215)
For $k = 1 To $count
$s_Mid = StringMid($read, $i_done, 16777215)
$a_AArr = StringSplit($s_Mid, "")
For $i = 1 To $a_AArr[0]
If $a_AArr[$i] = "0" And $a_AArr[$i + 1] = "x" Then ContinueLoop
If $a_AArr[$i] = "x" And $a_AArr[$i - 1] = "0" Then ContinueLoop
Switch $a_AArr[$i]
Case "5"
$s_ret &= "0"
Case "4"
$s_ret &= "1"
Case "7"
$s_ret &= "2"
Case "6"
$s_ret &= "3"
Case "1"
$s_ret &= "4"
Case "0"
$s_ret &= "5"
Case "3"
$s_ret &= "6"
Case "2"
$s_ret &= "7"
Case "D"
$s_ret &= "8"
Case "C"
$s_ret &= "9"
Case "F"
$s_ret &= "A"
Case "E"
$s_ret &= "B"
Case "9"
$s_ret &= "C"
Case "8"
$s_ret &= "D"
Case "B"
$s_ret &= "E"
Case "A"
$s_ret &= "F"
EndSwitch
Next
$i_done += 16777215
Next
_ArrayAdd($ret_array, Binary($s_ret))
Until $exitdo = 1
FileClose($hFile)
Return $ret_array
EndFunc ;==>_DecodefileSchreib mal bitte den genauen Fehler auf, also auch Scriptzeile und so
-
mit welcher Datei hast du es getestet? Mit einer größeren Datei?
Die maximale Stringlänge ist 2147483647, wenn eine Datei größer ist könntest du mit
[autoit]FileRead ($hFile , 2147483646 )
[/autoit]
[autoit]
Den ersten Teil einlesen,
dannFileSetPos(hFile ,2147483646, 0)
[/autoit]
und das ganze nochmal (evtl in ner Schleife)
Dann kannst du auch diese Einschränkung umgehen -
Spoiler anzeigen
[autoit]Func _Decodefile($s_FileName)
[/autoit]
Local $a_AArr, $s_Mid,$read,$s_ret = "", $i_done = 1, $len,$count
$hFile = FileOpen($s_FileName, 16)
$read = FileRead($hFile)
$len = StringLen($read)
$count = Ceiling($len / 16777215)
For $k = 1 To $count
$s_Mid = StringMid($read, $i_done, 16777215)
$a_AArr = StringSplit($s_Mid, "")
For $i = 1 To $a_AArr[0]
If $a_AArr[$i] = "0" And $a_AArr[$i+1] = "x" Then ContinueLoop
If $a_AArr[$i] = "x" And $a_AArr[$i-1] = "0" Then ContinueLoop
Switch $a_AArr[$i]
Case "5"
$s_ret &= "0"
Case "4"
$s_ret &= "1"
Case "7"
$s_ret &= "2"
Case "6"
$s_ret &= "3"
Case "1"
$s_ret &= "4"
Case "0"
$s_ret &= "5"
Case "3"
$s_ret &= "6"
Case "2"
$s_ret &= "7"
Case "D"
$s_ret &= "8"
Case "C"
$s_ret &= "9"
Case "F"
$s_ret &= "A"
Case "E"
$s_ret &= "B"
Case "9"
$s_ret &= "C"
Case "8"
$s_ret &= "D"
Case "B"
$s_ret &= "E"
Case "A"
$s_ret &= "F"
EndSwitch
Next
$i_done += 16777215
Next
FileClose($hFile)
Return Binary($s_ret)
EndFunc ;==>_DecodefileSo hab das Decoden mal gemacht, sollte funktionieren.
bei mir gibts aber nen Fehler mit der zip32.dll, liegt aber wahrscheinlich dran, das ich nen 64Bit Rechner hab -
-
-
Spoiler anzeigen
[autoit]Run("notepad.exe")
[/autoit] [autoit][/autoit] [autoit]Global $Paused
[/autoit] [autoit][/autoit] [autoit]
HotKeySet("{ENTER}", "TogglePause")WinWaitActive("[CLASS:Notepad]")
[/autoit] [autoit][/autoit] [autoit]Send("Dies ist eine Testzeile vor Betätigen der Entertaste." & @LF)
[/autoit] [autoit][/autoit] [autoit]Send("Dies ist eine Testzeile vor Betätigen der Entertaste." & @LF)
[/autoit] [autoit][/autoit] [autoit]
; --------------------------------------------------------------------#include<Misc.au3>
[/autoit] [autoit][/autoit] [autoit]$dll = DllOpen("user32.dll")
[/autoit] [autoit][/autoit] [autoit]TogglePause()
[/autoit] [autoit][/autoit] [autoit]DllClose($dll)
[/autoit] [autoit][/autoit] [autoit]
; --------------------------------------------------------------------Sleep(500)
[/autoit] [autoit][/autoit] [autoit]Send(@LF)
[/autoit] [autoit][/autoit] [autoit]Send(@LF)
[/autoit] [autoit][/autoit] [autoit]Send("Dies ist eine Testzeile nach Betätigen der Entertaste." & @LF)
[/autoit] [autoit][/autoit] [autoit]Send("Dies ist eine Testzeile nach Betätigen der Entertaste." & @LF)
[/autoit] [autoit][/autoit] [autoit]Exit
[/autoit] [autoit][/autoit] [autoit]Func TogglePause()
[/autoit] [autoit][/autoit] [autoit][/autoit]
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"',0,0)
WEnd
ToolTip("")
EndFuncWobei ich dabei aufpassen würde, da immer wenn du Enter drückst auch die Pause betätigt wird
-
-
-
-
-
Hallo liebe Community,
Ich will zur Zeit ein logfile auslesen ( 370000 Zeilen).
Dabei brauche ich nur bestimmte Teile des Logfiles ( immer der selbe String).Hier mal das momentane Script:
Spoiler anzeigen
[autoit]#include <Constants.au3>
[/autoit]
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <Arraymore.au3>
#include <Array.au3>
_SQLite_Startup()
$t = _SQLite_Open(@ScriptDir & "\" & "Datenbank.db")
$path = "C:\Temp\20111107.log"
$hFile = FileOpen($path, 0)
$read = FileRead($hFile)
$Splitcount = StringSplit($read, "Trennstring", 1)
$cnt = $Splitcount[0]
$Splitcount = ""
ProgressOn("Log Datei lesen", "Log Datei wird eingelesen")
For $i = 1 To $cnt+1
ProgressSet($i/($cnt+1) * 100)
$findkamp = StringInStr($read, "Trennstring", 0, $i)
If @error = 1 Or $findkamp = 0 Then
ProgressOff()
Exit
EndIf
FileSetPos($hFile, $findkamp - 77, $FILE_BEGIN)
$Time = FileRead($hFile, 19)
$find2 = StringInStr($read, "Statistic:", 0, 1, $findkamp, 150)
If $find2 <> "" Then
$Timesplit = Stringsplit($Time, " ")
$Date = $Timesplit[1]
$Uhrzeit = $Timesplit[2]
$findlast = StringInStr($read, "RunningTime", 0, 1, $find2 + 13)
FileSetPos($hFile, $find2 + 13, $FILE_BEGIN)
$readinhalt = FileRead($hFile, $findlast - 5 - $find2 + 13)
$Split = Stringsplit($readinhalt, @CRLF)
$Columns = "Datum,UHRZEIT"
For $k = 1 To $Split[0]
If $Split[$k] = "" THen ContinueLoop
$tmpsplit = Stringsplit($Split[$k], " = ", 1)
$Columns &= ","&$tmpsplit[1]
Next
$txt = 'Begin Transaction ;' & @CRLF
$txt &="INSERT INTO Daten ("&$Columns&") VALUES ('"&$Date&"','"&$Uhrzeit&"'"
For $k = 1 To $Split[0]
If $Split[$k] = "" THen ContinueLoop
$tmpsplit = Stringsplit($Split[$k], " = ", 1)
$txt &= ", '"&$tmpsplit[2]&"'"
Next
$txt &= ");"&@CRLF
$txt &= 'Commit Transaction ;' & @CRLF
_SQLite_Exec(-1, $txt)
_SQLite_Exec(-1, "DELETE FROM Daten WHERE AgentCount = '0';")
Else
ContinueLoop
EndIfWie ihr seht arbeite ich im moment mit
[autoit]StringInStr($read, "Trennstring", 0, $i)
[/autoit]
Damit wird immer wieder die gesamte Datei durchsucht, bis zum x-ten Vorkommen des Trennstrings.
Jetzt hatte ich überlegt, ob ich nicht vom Beginn der Datei bis zu $findlast, also dem letzten Zeichen das ich brauche, alles lösche und dann von vorne beginne. Damit sollte dann ja die Laufzeit kürzer werden, da der String kleiner ist (richtig?)Ich denke ich muss mit FileSetPos arbeiten, weiß aber nicht, wie ich dann etwas lösche, überschreiben steht ja in der Hilfe.
Weiß jemand wie das funktionieren könnte oder hat eine bessere Idee?
Das Programm an sich funktioniert, es dauert nur fast 10 Minuten pro Datei und das ist mir eindeutig zu langsam

-
Hatte extra eine Forschleife genommen aber wohl das To vergessen

Wenn alle Fragen gestellt wurden ( 13 Fragen, 100 mal zufall sollte eigentlich passen) wählt er eine Frage nochmals aus.
Die While Do Schleife wird aber niemals beendet, wenn alle Fragen gestellt wurdenAlso einfach die Forschleife so ändern:
[autoit]For $i = 1 To 100
[/autoit] -
Spoiler anzeigen
[autoit]#include <ButtonConstants.au3>
[/autoit] [autoit][/autoit] [autoit]
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <array.au3>
;~ ===================================================================================================================================
$vDLL = 'user32.dll'
$Masze = GUICreate("Maße", 490, 440, 400, 180)
$bImg = GUICtrlCreatePic("C:\Users\Stoani\Pictures\asdasd.jpg", 0, 0, 490, 440)
GUICtrlSetState(-1, $GUI_DISABLE)
$frage_button = GUICtrlCreateButton("Neue Frage", 10, 392, 196, 33)
GUICtrlSetFont(-1, 12, 400, 0, "Tw Cen MT Condensed")
$loesung_button = GUICtrlCreateButton("Lösung zeigen", 10, 352, 97, 33)
GUICtrlSetFont(-1, 12, 400, 0, "Tw Cen MT Condensed")
$Antwort = GUICtrlCreateInput("", 16, 184, 185, 27, BitOR($ES_CENTER, $WS_BORDER), 0)
GUICtrlSetFont(-1, 12, 400, 0, "Tw Cen MT Condensed")
GUICtrlSetColor(-1, 0x000000)
$Liste = GUICtrlCreateEdit("", 216, 16, 265, 409, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $WS_BORDER), 0)
GUICtrlSetData(-1, "Noch keine Frage gestellt!")
GUICtrlSetFont(-1, 12, 400, 0, "Tw Cen MT Condensed")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$Frage = GUICtrlCreateEdit("", 16, 16, 185, 57, BitOR($ES_CENTER, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_BORDER), 0)
GUICtrlSetData(-1, "")
GUICtrlSetFont(-1, 12, 400, 0, "Tw Cen MT Condensed")
GUICtrlSetColor(-1, 0x000000)
$go_button = GUICtrlCreateButton("Go!", 109, 352, 97, 33)
GUICtrlSetFont(-1, 12, 400, 0, "Tw Cen MT Condensed")
GUISetState()
;~ ===================================================================================================================================
Global $Read, $index, $i = 0
;~ ====================================
Global $mA[14][3]$mA[0][0] = "Wie lange ist der Korpus ?"
[/autoit]
$mA[0][1] = "356mm"
$mA[0][2] = 0
$mA[1][2] = 0
$mA[2][2] = 0
$mA[3][2] = 0
$mA[4][2] = 0
$mA[5][2] = 0
$mA[6][2] = 0
$mA[7][2] = 0
$mA[8][2] = 0
$mA[9][2] = 0
$mA[10][2] = 0
$mA[11][2] = 0
$mA[12][2] = 0
$mA[13][2] = 0
$mA[1][0] = "Wie lange ist die Korpusmensur ?"
$mA[1][1] = "195mm"
$mA[2][0] = "Wie lange ist die Halsmensur ?"
$mA[2][1] = "130mm"
$mA[3][0] = "Wieviel beträgt die Halsstärke am Sattel(exklusive Griffbrett)?"
$mA[3][1] = "13mm"
$mA[4][0] = "Wieviel beträgt die Halsstärke vor dem Halsfuß(exklusive Griffbrett)?"
$mA[4][1] = "14mm"
$mA[5][0] = "Wieviel beträgt die Halsstärke am Sattel(inklusive Griffbrett)?"
$mA[5][1] = "19mm"
$mA[6][0] = "Wieviel beträgt die Halsstärke am Sattel(inklusive Griffbrett)?"
$mA[6][1] = "21mm"
$mA[7][0] = "Wie hoch ist der Randüberstand ?"
$mA[7][1] = "6mm"
$mA[8][0] = "Wie lange ist das Griffbrett ?"
$mA[8][1] = "270mm"
$mA[9][0] = "Wie breit ist das Griffbrett am Sattel ?"
$mA[9][1] = "23,5mm"
$mA[10][0] = "Wie breit ist das Griffbrett am Hals. -Korpusübergang ?"
$mA[10][1] = "42mm"
$mA[11][0] = "Wie hoch ist der Griffbrettrand ?"
$mA[11][1] = "5mm"
$mA[12][0] = "Wie stark ist die Griffbretthohlung unter der Diskantsaite ?"
$mA[12][1] = "0,5mm"
$mA[13][0] = "Wie stark ist die Griffbretthohlung unter der Basssaite ?"
$mA[13][1] = "0,7mm"
;~ =======================================================================
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $frage_button
For $i = 100; sucht eine Zahl, bis eine noch nicht gestellte Frage gefunden wurde
$index = Random(0, UBound($mA) - 1, 1)
If $mA[$index][2] = 0 Then ExitLoop
Next
$cRead = $mA[$index][0]
GUICtrlSetData($Frage, $cRead)
$mA[$index][2] = 1 ; setzt Frage als bereits gestellt
Case $loesung_button
$i = $i + 1
ConsoleWrite($i)
If $i = 10 Then
MsgBox(0, "", "Du hast bereits 10mal die Lösung gebraucht! Bitte nochmal probieren!")
$i = 0
Exit
EndIf
GUICtrlSetData($Liste, "Die Lösung ist: " & $mA[$index][1])
Case $go_button
$Read = GUICtrlRead($Antwort)
If $Read <> $mA[$index][1] Then
GUICtrlSetData($Liste, "Falsche Antwort!" & @CRLF & "Lösung anzeigen?")
ElseIf $Read = $mA[$index][1] Then
GUICtrlSetData($Liste, "Das Maß beträgt " & $Read & "!" & @CRLF & "Richtige Antwort!")
EndIf
EndSwitch
WEndich hab dein Array um eine Spalte erweitert, die Änderungen habe ich kommentiert, sollte eigentlich einleuchtend sein
-
Hier mal ein Beispiel, was ich für eines meiner projekte gebraucht habe:
[autoit]$hRequest = _WinHttpOpenRequest($hConnect, "POST", "/powerq1/statistik.php", "HTTP/1.1") ; Startet den Request
[/autoit]
_WinHttpSendRequest($hRequest, "Content-Type: application/x-www-form-urlencoded" & @CRLF)
_WinHttpReceiveResponse($hRequest) ; liefert den HTML QUellcode der Aufgerufenen Seite
Local $data = ""
Do
$data &= _WinHttpReadData($hRequest)
Until @error
$data = StringReplace($data, "<td >", "") ; löscht alle <td>
$data = StringReplace($data, "</td>", "") ; löscht alle </td>
$data = StringReplace($data, '<td class="right">', ""); löscht alle '<td class="right">'
$data = StringStripWS($data, 4) ; löscht überflüssige Leerzeichen
$avArray = _StringBetween($data, 'id="row', "</tr>") ;Sucht die spalten
If @error Then ; wenn keine Spalten gefunden wurden
Return 0
EndIf
For $i = 0 To UBound($avArray) - 1
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $avArray[$i] = ' & $avArray[$i] & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
NextDu musst zuerst die Stringposition raussuchen (oberer Teil)
in der unteren Schleife kannst du dann mit IsNumber($avArray) überprüfen, ob der gefundene Wert eine Zahl ist.Ich habe hier mit HTTP Requests gearbeitet, aber dasselbe geht auch InetRead und BinarytoString