well, i will be very happy if you helped me i was trying all the scripts but im always having the script paused problem
#include <Array.au3>
#include <Timers.au3>
#include <WinAPIProc.au3>
Global $sProductFilePath = @WindowsDir
Global $sProductFileName = "Notepad.exe"
Global $sProductName = FileGetVersion($sProductFilePath & "\" & $sProductFileName, "ProductName")
Global $hProcessWnd, $aProcessList, $idMsgBox
Global $iTimerInit = TimerInit()
Global $iIdleTime = _Timer_GetIdleTime()
While 1
$aProcessList = ProcessList($sProductFileName)
If $aProcessList[0][0] >= 2 Then
$idMsgBox = MsgBox(48, $sProductName, "Multiple Licenses Detected" & @CRLF & @CRLF & "Due to license limitations only one copy of " & $sProductName & " is allowed." & @CRLF & @CRLF & "Please close additional copies of " & $sProductName)
$iTimerInit = TimerInit()
ContinueLoop
EndIf
$iProcessId = ProcessExists($sProductFileName)
If $iProcessId Then
$iIdleTime = _Timer_GetIdleTime()
$hProcessWnd = _GetHwndFromPID($iProcessId)
If WinActive($hProcessWnd ) Then
$iTimerInit = TimerInit()
EndIf
;~ If the timer is more than 40 minutes then send message to user and close the process, otherwise it closes within 5 minutes
If TimerDiff($iTimerInit) >= 40 * 60 * 1000 Or $iIdleTime >= 40 * 60 * 1000 Then
$idMsgBox = MsgBox(48, $sProductName, $sProductName & " has been idle for more than 40 minutes and will be closed in 5 minutes if no activity is detected.", 300)
If $idMsgBox = -1 Then ProcessClose($sProductFileName)
EndIf
EndIf
Sleep(100)
WEnd
;Function for getting HWND from PID
Func _GetHwndFromPID($_iProcessId)
Local $_hProcessWnd
Local $iWinList, $_aWinList = WinList()
For $i = 1 To $_aWinList[0][0]
If $_aWinList[$i][0] <> "" Then
$iWinList = WinGetProcess($_aWinList[$i][1])
If $iWinList = $_iProcessId Then
$_hProcessWnd = $_aWinList[$i][1]
ExitLoop
EndIf
EndIf
Next
Return $_hProcessWnd
EndFunc;==>_GetHwndFromPID