使用apple script管理进程

代码如下:

tell application "System Events"
	set listOfProcesses to (name of every process where background only is false)
	tell me to set selectedProcesses to choose from list listOfProcesses with multiple selections allowed
end tell
--The variable `selectedProcesses` will contain the list of selected items.
repeat with processName in selectedProcesses
	do shell script "Killall " & quoted form of processName
end repeat

和系统的活动监视器相比,好处在于只有前台进程。

☆版权☆

* 网站名称:obaby@mars
* 网址:https://h4ck.org.cn/
* 个性:https://oba.by/
* 本文标题: 《使用apple script管理进程》
* 本文链接:https://h4ck.org.cn/2018/11/6255
* 短链接:https://oba.by/?p=6255
* 转载文章请标明文章来源,原文标题以及原文链接。请遵从 《署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5 CN) 》许可协议。


猜你喜欢:

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注