Hallo zusammen,
ich habe ein Problem mit meinem Script.
Immer wenn ich auf den 'Weiter' Butten drücke stürzt es ab (._.)
Ich weiß einfach nicht warum, ich hoffe Ihr könnt mir helfen.
Spoiler anzeigen
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <File.au3>
#include <Array.au3>
#include <RecFileListToArray.au3>
#NoTrayIcon
#RequireAdmin
#include-once
FileInstall("header.JPG",@tempdir&"\header.JPG")
FileInstall('ag.ico', @TempDir & '\ag.ico')
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=c:\users\delux\desktop\form1.kxf
$Form1_1 = GUICreate("PC-Bereinigung.", 645, 442)
GUISetBkColor(0xFFFFFF)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
$Pic1 = GUICtrlCreatePic(@tempdir&"\header.JPG", 0, 0,645, 100)
$idPB_AddTicket = GUICtrlCreatePic('', 8, 16, 64, 64)
__SetIconAlpha($idPB_AddTicket, @TempDir & '\ag.ico', 0, 64, 64)
$Label1 = GUICtrlCreateLabel("PC-Bereinigung", 80, 34, 237, 30)
GUICtrlSetFont(-1, 12, 800, 0, "Tahoma")
GUICtrlSetBkColor(-1, -2)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label2 = GUICtrlCreateLabel("Verbessern Sie die Leistung ihres Computers.", 80, 56, 299, 22)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
GUICtrlSetBkColor(-1, -2)
GUICtrlSetColor(-1, 0xFFFFFF)
$Group1 = GUICtrlCreateGroup("", 8, 104, 631, 329)
$Label3 = GUICtrlCreateLabel("Wichtiger Hinweis", 16, 120, 119, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
$Label4 = GUICtrlCreateLabel("Durch die Bereinigung wird die Leistung Ihres Computers verbessert, indem Objekte entfernt werden, die", 16, 144, 605, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
$Label10 = GUICtrlCreateLabel("nicht mehr gebraucht werden, z.B. temporäre Internetdateien und Cookies. Es werden keine aktuellen", 16, 160, 587, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
$Button1 = GUICtrlCreateButton("Weiter", 501, 392, 131, 33)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
GUICtrlSetOnEvent(-1,"_CleanUpAll")
$Button2 = GUICtrlCreateButton("Abbrechen", 15, 392, 131, 33)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
GUICtrlSetOnEvent(-1,"_Exit")
$Label5 = GUICtrlCreateLabel("Dateien gelöscht.", 16, 176, 102, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
$Label6 = GUICtrlCreateLabel("Folgende Browser werden bereinigt", 16, 208, 234, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
$Label7 = GUICtrlCreateLabel("• Mozilla-Firefox", 16, 232, 97, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
$Label8 = GUICtrlCreateLabel("• Internet-Explorer", 16, 256, 111, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
$Label9 = GUICtrlCreateLabel("• Google-Chrome", 16, 280, 102, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
$Label11 = GUICtrlCreateLabel("Klicken Sie auf 'Weiter' um den Vorgang zu starten.", 16, 368, 318, 20)
GUICtrlSetFont(-1, 10, 400, 4, "Tahoma")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$2Form1_1 = GUICreate("PC-Bereinigung.", 645, 442)
GUISetBkColor(0xFFFFFF)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
$Pic21 = GUICtrlCreatePic(@TempDir & '\header.JPG', 0, 0,645, 100)
$idPB_AddTicket2 = GUICtrlCreatePic('', 8, 16, 64, 64)
__SetIconAlpha($idPB_AddTicket2, @TempDir & '\ag.ico', 0, 64, 64)
$2Label1 = GUICtrlCreateLabel("PC-Bereinigung", 80, 34, 237, 30)
GUICtrlSetFont(-1, 12, 800, 0, "Tahoma")
GUICtrlSetBkColor(-1, -2)
GUICtrlSetColor(-1, 0xFFFFFF)
$2Label2 = GUICtrlCreateLabel("Verbessern Sie die Leistung ihres Computers.", 80, 56, 299, 22)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
GUICtrlSetBkColor(-1, -2)
GUICtrlSetColor(-1, 0xFFFFFF)
$2Group1 = GUICtrlCreateGroup("", 8, 104, 631, 329)
$2Label3 = GUICtrlCreateLabel("Wichtiger Hinweis", 16, 120, 119, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
$2Label4 = GUICtrlCreateLabel("Durch die Bereinigung wird die Leistung Ihres Computers verbessert, indem Objekte entfernt werden, die", 16, 144, 605, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
$2Label10 = GUICtrlCreateLabel("nicht mehr gebraucht werden, z.B. temporäre Internetdateien und Cookies. Es werden keine aktuellen", 16, 160, 587, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
$2Button1 = GUICtrlCreateButton("Weiter", 501, 392, 131, 33)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlSetOnEvent(-1,"_Exit")
$2Button2 = GUICtrlCreateButton("Abbrechen", 15, 392, 131, 33)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
GUICtrlSetOnEvent(-1,"_Exit")
$2Label5 = GUICtrlCreateLabel("Dateien gelöscht.", 16, 176, 102, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
$2Label6 = GUICtrlCreateLabel("Status", 16, 208, 47, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Tahoma")
$2Label9 = GUICtrlCreateLabel("Cookies und temporäre Internetdateien werden entfernt...", 16, 232, 336, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Tahoma")
$2Label11 = GUICtrlCreateLabel("Klicken Sie auf 'Weiter' um den Vorgang abzuschließen.", 16, 368, 322, 20)
GUICtrlSetFont(-1, 10, 400, 4, "Tahoma")
$2Progress1 = GUICtrlCreateProgress(16, 248, 614, 29)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_HIDE)
While 1
Sleep(100)
WEnd
Func _Exit()
Exit
EndFunc
Func _CleanUpAll()
GUISetState(@SW_SHOW,$2Form1_1)
GUISetState(@SW_HIDE,$Form1_1)
GUICtrlSetData($2Progress1,5)
clean_profiles()
GUICtrlSetData($2Progress1,100)
GUICtrlSetState($2Button1,$GUI_DISABLE)
EndFunc
func clean_profiles()
[/autoit] [autoit][/autoit] [autoit]$userdir = StringTrimRight( @userprofiledir , stringlen (@username) +1 ) ; $userdir = path of users directories. For example, C:\Users for Windows 7
$listing = _FileListToArray($userdir, "*", 2) ;returns an array containing the name of all users directories
$i = 1
[/autoit] [autoit][/autoit] [autoit]Do
if stringinstr(FileGetAttrib($userdir & "\" & $listing[$i]), "H") <> 0 then ;if the folder has "hidden" as attribute (system user), we remove it from $listing array
_arraydelete($listing, $i)
$listing[0] = $listing[0] - 1
Else
$i = $i+1
endif
until $listing[0] == $i
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]for $i = 1 to $listing[0] step 1 ; for all user directories, we clean the below folders:
[/autoit] [autoit][/autoit] [autoit]if @OSVersion == "WIN_7" then
[/autoit] [autoit][/autoit] [autoit]delfolder($userdir & "\" & $listing[$i] & "\AppData\Local\Microsoft\Windows\Temporary Internet Files")
GUICtrlSetData($2Progress1,10)
delfolder($userdir & "\" & $listing[$i] & "\AppData\Local\Temp")
GUICtrlSetData($2Progress1,20)
delfolder($userdir & "\" & $listing[$i] & "\AppData\LocalLow\Temp")
GUICtrlSetData($2Progress1,30)
delfolder($userdir & "\" & $listing[$i] & "\AppData\Local\Google\Chrome\User Data\Default\Cache")
GUICtrlSetData($2Progress1,40)
$firefox = _FileListToArray(@Homedrive & "\Users\" & $listing[$i] & "\AppData\Local\Mozilla\Firefox\Profiles", "*", 2)
[/autoit] [autoit][/autoit] [autoit]if IsArray($firefox) then ; if at least 1 firefox profile is found, we clean it/them
[/autoit] [autoit][/autoit] [autoit]for $k = 1 to $firefox[0] step 1
[/autoit] [autoit][/autoit] [autoit]delfolder($userdir & "\" & $listing[$i] & "\AppData\Local\Mozilla\Firefox\Profiles\" & $firefox[$k] & "\Cache")
GUICtrlSetData($2Progress1,50)
delfolder($userdir & "\" & $listing[$i] & "\AppData\Local\Mozilla\Firefox\Profiles\" & $firefox[$k] & "\OfflineCache")
GUICtrlSetData($2Progress1,60)
delfolder($userdir & "\" & $listing[$i] & "\AppData\Local\Mozilla\Firefox\Profiles\" & $firefox[$k] & "\startupCache")
GUICtrlSetData($2Progress1,70)
next
[/autoit] [autoit][/autoit] [autoit]endif
[/autoit] [autoit][/autoit] [autoit]elseif @OSVersion == "WIN_XP" Then
[/autoit] [autoit][/autoit] [autoit]delfolder($userdir & "\" & $listing[$i] & "\Local Settings\Temporary Internet Files")
GUICtrlSetData($2Progress1,10)
delfolder($userdir & "\" & $listing[$i] & "\Local Settings\Temp")
GUICtrlSetData($2Progress1,20)
delfolder($userdir & "\" & $listing[$i] & "\Local Settings\Application Data\Google\Chrome\User Data\Default\Cache")
GUICtrlSetData($2Progress1,30)
$firefox = _FileListToArray(@Homedrive & "\Users\" & $listing[$i] & "\AppData\Local\Mozilla\Firefox\Profiles", "*", 2)
[/autoit] [autoit][/autoit] [autoit]if IsArray($firefox) then ; if at least 1 firefox profile is found, we clean it/them
[/autoit] [autoit][/autoit] [autoit]for $k = 1 to $firefox[0] step 1
[/autoit] [autoit][/autoit] [autoit]delfolder($userdir & "\" & $listing[$i] & "\AppData\Local\Mozilla\Firefox\Profiles\" & $firefox[$k] & "\Cache")
GUICtrlSetData($2Progress1,40)
delfolder($userdir & "\" & $listing[$i] & "\AppData\Local\Mozilla\Firefox\Profiles\" & $firefox[$k] & "\OfflineCache")
GUICtrlSetData($2Progress1,50)
delfolder($userdir & "\" & $listing[$i] & "\AppData\Local\Mozilla\Firefox\Profiles\" & $firefox[$k] & "\startupCache")
GUICtrlSetData($2Progress1,60)
next
[/autoit] [autoit][/autoit] [autoit]endif
[/autoit] [autoit][/autoit] [autoit]endif
[/autoit] [autoit][/autoit] [autoit]next
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]func delfolder ($folder)
[/autoit] [autoit][/autoit] [autoit]$dirlisting = _RecFileListToArray($folder, "*", 14, 1) ;getting all folders/subfolders into an array
[/autoit] [autoit][/autoit] [autoit]if isArray($dirlisting) then ;if the folder contains subfolder, we delete everything inside each subfolders
[/autoit] [autoit][/autoit] [autoit]filedelete($folder & "\*.*")
[/autoit] [autoit][/autoit] [autoit]for $i = 1 to $dirlisting[0] step 1
[/autoit] [autoit][/autoit] [autoit]filedelete($folder & "\" & $dirlisting[$i] & "\*.*")
Dirremove($folder & "\" & $dirlisting[$i], 1)
next
else ;if the folder doesn't contains subfolder, we simply delete what's inside it.
[/autoit] [autoit][/autoit] [autoit]filedelete($folder & "\*.*")
[/autoit] [autoit][/autoit] [autoit]endif
[/autoit] [autoit][/autoit] [autoit]endfunc
[/autoit] [autoit][/autoit] [autoit]Func __SetIconAlpha($hWnd, $sIcon, $iIndex, $iWidth, $iHeight)
If Not IsHWnd($hWnd) Then
$hWnd = GUICtrlGetHandle($hWnd)
If $hWnd = 0 Then
Return SetError(1, 0, 0)
EndIf
EndIf
Local $hIcon = __WinAPI_ShellExtractIcons($sIcon, $iIndex, $iWidth, $iHeight)
If $hIcon = 0 Then
Return SetError(1, 0, 0)
EndIf
Local $hBitmap, $hObj, $hDC, $hMem, $hSv
$hDC = _WinAPI_GetDC($hWnd)
$hMem = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
$hSv = _WinAPI_SelectObject($hMem, $hBitmap)
_WinAPI_DrawIconEx($hMem, 0, 0, $hIcon, $iWidth, $iHeight, 0, 0, 2)
_WinAPI_ReleaseDC($hWnd, $hDC)
_WinAPI_SelectObject($hMem, $hSv)
_WinAPI_DeleteDC($hMem)
_WinAPI_DestroyIcon($hIcon)
_WinAPI_DeleteObject(_SendMessage($hWnd, 0x0172, 0, 0))
_SendMessage($hWnd, 0x0172, 0, $hBitmap)
$hObj = _SendMessage($hWnd, 0x0173)
If $hObj <> $hBitmap Then
_WinAPI_DeleteObject($hBitmap)
EndIf
Return 1
EndFunc ;==>__SetIconAlpha
Func __WinAPI_ShellExtractIcons($sIcon, $iIndex, $iWidth, $iHeight)
Local $ret = DllCall('shell32.dll', 'int', 'SHExtractIconsW', 'wstr', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr*', 0, 'int', 1, 'int', 0)
If (@error) Or ($ret[0] = 0) Or ($ret[5] = Ptr(0)) Then
Return SetError(1, 0, 0)
EndIf
Return $ret[5]
EndFunc ;==>__WinAPI_ShellExtractIcons
Bilder,Icons und die Include stehen als Download bereit:
autoit.de/wcf/attachment/20857/