autoit script help!

savinio0

New member
Member
Local time
10:16 AM
Messages
73
Hi all
On this wonderful forum i found this autoit interesting script:
How to close a software automatically when it's idle? - Windows 7 Help Forums

Can someone modify this script to STOP and Close automatically ''My-Xtool.exe'' from processes?not from aplications,but only when is idle for more then 1 min.,is possible that?
I run My-Xtool.exe and i see how bytes values are changing,but sometimes that values are static they don't change value anymore that means my .exe goes IDLE,then i want to stop the process automatically,can anyone help me with that please?
thank you
 

My Computer

Computer type
PC/Desktop
OS
windows xp c86
UsernameIssues’ original script used the window title to identify a process, but it appears you want to identify a process by its name instead (“My-Xtool.exe”), so I’ve written a new solution that does this.

Code:
;;;
Local $sProcessName = 'notepad.exe'
Local $iTimeDelta = 60 * 1000 ; one minute
;;;

Func _WinHwndListFromPID($iPID)
   Local $aWinHwndList[1][2]

   Local $aWinList = WinList()
   For $i = 1 To $aWinList[0][0]
	  If (WinGetProcess($aWinList[$i][1]) = $iPID) And BitAND(WinGetState($aWinList[$i][1]), 1) Then
		 $iListSize = UBound($aWinHwndList)
		 ReDim $aWinHwndList[$iListSize + 1][2]
		 $aWinHwndList[$iListSize][0] = $aWinList[$i][0]
		 $aWinHwndList[$iListSize][1] = $aWinList[$i][1]
	  EndIf
   Next

   $aWinHwndList[0][0] = UBound($aWinHwndList) - 1

   Return $aWinHwndList
EndFunc

If Not ProcessExists($sProcessName) Then
   MsgBox(48, 'Process not found', 'The process "' & $sProcessName & '" could not be found. The script will continue executing.')
EndIf

Local $fTimer = TimerInit()
While 1
   ConsoleWrite(TimerDiff($fTimer) & [USER=277225]CRL[/USER]F)

   $aWinList = _WinHwndListFromPID(ProcessExists($sProcessName))

   If $aWinList[0][0] Then
	  If BitAND(WinGetState($aWinList[1][1]), 8) Then
		 $fTimer = TimerInit()
	  EndIf
   EndIf

   If TimerDiff($fTimer) >= $iTimeDelta Then
	  ProcessClose($sProcessName)
   EndIf

   Sleep(1000)
WEnd
 

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Back
Top