#include <GuiConstantsEx.au3> Global Const $PROCESS_ALL_ACCESS = 0x1F0FFF $hGUI = GUICreate("Test GUI", 300, 200) GUISetState() _ProcessReduceMemory(@AutoItPID) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _ProcessReduceMemory($iPID) Local $iProcExists = ProcessExists($iPID) ;To get the PID and check process existence Local $hOpenProc, $aResult If Not $iProcExists Then Return SetError(1, 0, 0) If IsString($iPID) Then $iPID = $iProcExists $hOpenProc = DllCall('Kernel32.dll', 'int', 'OpenProcess', 'int', $PROCESS_ALL_ACCESS, 'int', False, 'int', $iPID) $aResult = DllCall("Kernel32.dll", "int", "SetProcessWorkingSetSize", "hwnd", $hOpenProc[0], "int", -1, "int", -1) DllCall('Kernel32.dll', 'int', 'CloseHandle', 'int', $hOpenProc[0]) If Not IsArray($aResult) Or $aResult[0] = 0 Then Return SetError(2, 0, 0) Return $aResult[0] EndFunc |