autoit script help!


  1. Posts : 73
    windows xp c86
       #1

    autoit script help!


    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


  2. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #2

    @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) & @CRLF)
    
       $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


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 17:46.
Find Us