#include<WinAPI.au3>
#include<StructureConstants.au3>
#include<WindowsConstants.au3>
OnAutoItExitRegister("__Exit")
Global $trTime
$hStub=DllCallbackRegister("__Event","long","int;wparam;lparam")
$hModule=_WinAPI_GetModuleHandle(0)
$hHookM=_WinAPI_SetWindowsHookEx($wh_mouse_ll,DllCallbackGetPtr($hStub),$hModule)
While 1
Sleep(200)
$trTime+=200
If $trTime=(5*60*1000) Then
$trTime=0
ProcessWaitClose(Run("defrag.exe D:",'',@SW_HIDE))
EndIf
WEnd
Func __Event($nCode,$wPar,$lPar)
If $nCode<0 Then Return _WinAPI_CallNextHookEx($hHookM,$nCode,$wPar,$lPar)
Local $tKEY=BitAND($wPar,0xFFFF)
If $tKEY=$wm_mousemove Then
$trTime=0
ProcessClose("defrag.exe")
EndIf
EndFunc
Func __Exit()
_WinAPI_UnhookWindowsHookEx($hHookM)
DllCallbackFree($hStub)
EndFunc