#NoTrayIcon;這一段是不讓程序圖標顯示在通知檔位,根據個人需要來決定是否開啟此功能
#include <Excel.au3>
HotKeySet("{ESC}", "Terminate")
While 1
sleep(100)
_ReduceMemory(@AutoItPID)
If WinExists("你的視窗標題") Then
ControlClick("你的視窗標題","","你的視窗控制項ID")
MsgBox(4096, "提示", "窗口已經關閉",3);這一段可以不要
EndIf
_ReduceMemory(@AutoItPID)
WEnd
_ReduceMemory(@AutoItPID)
Func Terminate()
Exit
EndFunc
_ReduceMemory(@AutoItPID)
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
|