#include <process.au3>
If WinExists("RAM_Clean") Then Exit
AutoItWinSetTitle("RAM_Clean")
FileInstall("empty.exe", @TempDir & "\empty.exe")
HotKeySet("!{Pause}", "_RAM_Clean")
HotKeySet("!{Del}", "Delete")
Break(0)
Local $T, $I, $L
Input_timer()
TraySetToolTip("自动整理间隔为:" & $T & "分钟" & @LF & "按ALT+PAUSE立即整理,按ALT+DEL退出!")
While 1
Call("Clean")
Sleep(4000)
TrayTip("", "", 1)
Sleep(($T * 60000) - 8000)
WEnd
Func _RAM_Clean()
TrayTip("", "开始整理内存...", 1)
$mem = MemGetStats()
$list = ProcessList()
For $I = 1 To $list[0][0]
$line = "empty.exe" & Chr(32) & $list[$I][1]
If $list[$I][1] <> 0 And $list[$I][1] <> 4 Then
RunWait(@ComSpec & " /c " & $line, "", @SW_HIDE)
EndIf
Next
$mem1 = MemGetStats()
$var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "EnableBalloonTips")
If $var = 0 Then
ToolTip("整理前可用/整理后可用" & Chr(13) & Chr(13) & Round($mem[2] / 1024, 1) & "/" & Round($mem1[2] / 1024, 1) & Chr(32) & "MB", @DesktopWidth - 135, @DesktopHeight - 76)
Sleep(4000)
ToolTip("")
Else
TrayTip("整理前可用/整理后可用", Round($mem[2] / 1024, 1) & "/" & Round($mem1[2] / 1024, 1) & Chr(32) & "MB", 4, 1)
Sleep(4000)
EndIf
TrayTip("", "内存整理结束...", 1)
EndFunc ;==>Clean
Func Delete()
FileDelete(@TempDir & "\empty.exe")
Exit
EndFunc ;==>Delete
Func Input_timer()
$T = InputBox("内存整理", "自动整理的间隔时间(分钟)", 20, " 2", 190, 115, -1, -1, 6)
Select
Case @error = 1 Or @error = 3
Exit
Case @error = 2
$T = 10
Case StringIsDigit($T) = 0
Input_timer()
EndSelect
EndFunc ;==>Input_timer
|