CODICE
;reduce memory by Misterx
#NoTrayIcon
#include <GuiConstants.au3>
#include <GuiListBox.au3>
Global $title="Reduce memory-by Misterx"
GUICreate($title,465,305)
$proclist=GUICtrlCreateList("",0,0,200,305)
_list()
GUICtrlCreateGroup("Process info",210,0,247,300)
$info=GUICtrlCreateButton("Info",220,20,227,20)
$aggiorna=GUICtrlCreateButton("Aggiorna liste",220,43,227,20)
$redmem=GUICtrlCreateButton("Riduci memoria",220,67,227,20)
$infolist=GUICtrlCreateListView("Processo |Pid |Memoria",220,90,227,200)
GUISetState()
While 1
Switch GUIGetMsg()
Case $gui_event_close
Exit
Case $info
$procinfo=GUICtrlRead($proclist)
If $procinfo="" Then
MsgBox(48,$title,"Selezionare il processo!",3)
Else
$pid=ProcessExists($procinfo)
If Not $pid=@error Then
$memory=ProcessGetStats($procinfo,0)
If $memory=0 Then
GUICtrlCreateListViewItem($procinfo &"|"& $pid &"|Impossibile leggere memoria",$infolist)
Else
GUICtrlCreateListViewItem($procinfo &"|"& $pid &"|"& Round(($memory[0]/1000),0)& " Kb",$infolist)
EndIf
Else
MsgBox(16,$title,"Impossibile trovare il processo."& $procinfo,3)
EndIf
EndIf
Case $aggiorna
_GUICtrlListBox_Destroy($proclist)
$proclist=GUICtrlCreateList("",0,0,200,305)
_list()
_GUICtrlListBox_Destroy($infolist)
$infolist=GUICtrlCreateListView("Processo |Pid |Memoria",220,90,227,200)
Case $redmem
$procmem=GUICtrlRead($proclist)
If $procmem="" Then
MsgBox(48,$title,"Selezionare il processo!",3)
Else
$memopid=ProcessExists($procinfo)
If $memopid=@error Then
MsgBox(16,$title,"Impossibile trovare il processo "& $procmem,3)
Else
_ReduceMemory($memopid)
EndIf
EndIf
EndSwitch
WEnd
Func _ReduceMemory($i_PID = -1)
If $i_PID <> -1 Then
Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
Else
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
EndIf
Return $ai_Return[0]
EndFunc;==> _ReduceMemory()
Func _list()
$list=ProcessList()
For $i=1 to $list[0][0]
If Not StringInStr($list[$i][0],"[System Process]") Then
GUICtrlSetData($proclist,$list[$i][0])
EndIf
Next
EndFunc