我要做的是仅在用户不活动时才运行.exe。当屏幕再次变为活动状态时,脚本应再次启动。
逻辑:
While True:
Is the user active:
NO-> Is the .exe running -> Yes: Do nothing No: run the Program
YES -> Close the .exe
关于如何使用Auto It进行编程的任何建议
编辑:
不活动:无用户活动(移动鼠标或其他方式)运行程序:这是一个自定义.exe文件,将保存在同一文件夹中。
这是针对Windows而不是Linux机器的
_Timer_GetIdleTime()正是您所需要的。
返回自上次用户活动以来的滴答数(即,KYBD /鼠标)
用法示例:
#include <Timers.au3>
$InactivityTrigger = 5*1000 ;inactive for 5 seconds
$myExe = "calc.exe"
$PID = 0
While True
$InactiveFor = _Timer_GetIdleTime()
If $InactiveFor >= $InactivityTrigger And Not $PID Then
$PID = Run($myExe)
ConsoleWrite("started" & @CRLF)
ElseIf $InactiveFor < $InactivityTrigger And $PID Then
ProcessClose($PID)
$PID = 0
ConsoleWrite("stopped" & @CRLF)
EndIf
If Not $PID And Not IsFloat($InactiveFor/10) Then ToolTip("Inactive for: " & Round($InactiveFor/1000) & " seconds." & @CRLF & @CRLF & _
"Will run exe in " & Round( ($InactivityTrigger-$InactiveFor)/1000 ) & " seconds." )
Wend
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句