autoit 脚本帮助!当空闲 1 分钟时停止进程

autoit 脚本帮助!当空闲 1 分钟时停止进程

我发现了这个有趣的脚本:

Opt("WinTitleMatchMode", 3) ;3 = 精确标题匹配 Opt("TrayIconDebug", 1)

$S_running = "check-4-app" ;将脚本命名为 If WinExists($S_running) Then Exit AutoItWinSetTitle($S_running)

$title = "无标题 - 记事本" $count = 0 While 1 $state = WinGetState($title) $count += 1

If $state = 15 Or $state = 47 Or $state = 0 Then $count = 0

If $count > 10 Then WinClose($title)

ToolTip("count = " & $count, 0, 0, "state = " & $state)
Sleep(1000) WEnd

有人可以修改此脚本以自动停止并关闭“My-Xtool.exe”吗?不是从应用程序,而是仅在空闲时间超过 1 分钟时,可以吗?我很困惑

在 My-Xtool.exe 中,我看到字节值是如何变化的,但有时这些值是静态的,它们不再改变值,这意味着我的 .exe 进入空闲状态,然后我想自动停止该进程,有人能帮我吗?谢谢

答案1

使用和我类似的方法退出浏览器

Local $aList = 0
    Local $aProcesses = StringSplit('iexplore.exe|chrome.exe|firefox.exe|safari.exe|opera.exe|slimjet.exe', '|', $STR_NOCOUNT) ; Multiple processes
    For $i = 0 To UBound($aProcesses) - 1
        $aList = ProcessList($aProcesses[$i])
        If $aList[0][0] > 0 Then ; An array is returned and @error is NEVER set, so lets check the count.
;~         _ArrayDisplay($aList)
            Local $bIsProcessClosed = False ; Declare a variable to hold a boolean.
            For $j = 1 To $aList[0][0]
                $bIsProcessClosed = ProcessClose($aList[$j][1]) ; In AutoIt 0 or 1 can be considered boolean too. It's like a bit in SQL or in C, where 1 and 0 means true or false.
                If Not $bIsProcessClosed Then ConsoleWrite('CLOSE ERROR PID: ' & $aList[$j][1] & @CRLF)
            Next
        EndIf
    Next

相关内容