本文介绍了Applescript 可以列出放置在 Dock 中的所有应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何列出用户放置在 Dock 中的所有应用程序.

I can't work out how to list all the Applications that a user has placed in the dock.

这可能吗?

推荐答案

试试这个.这是一个人拥有的在 Dock 中持久存在的应用程序列表.我所做的基本上是使用系统事件将 plist 文件读入 pListItems 变量中的 applescript 记录.然后我可以使用applescript 技术访问pListItems 中的列表和记录.

Try this. This is a list of the apps a person has that are persistent in the dock. What I've basically done is use system events to read the plist file into an applescript record in the pListItems variable. Then I can use applescript techniques to access the lists and records inside of pListItems.

com.apple.dock 中有很多信息,因此您可以查看 pListItems 变量并通过它找出您需要的任何内容.例如,您可能需要|bundle-identifier|"而不是|file-label|".祝你好运.

There's lots of information in com.apple.dock so you can look at the pListItems variable and work your way through it to pull out whatever you need. For example you might want the "|bundle-identifier|" instead of the "|file-label|". Good luck.

set plistpath to (path to preferences folder as text) & "com.apple.dock.plist"

tell application "System Events"
    set plistContents to contents of property list file plistpath
    set pListItems to value of plistContents
end tell
set persistentAppsList to |persistent-apps| of pListItems

set dockAppsList to {}
repeat with thisRecord in persistentAppsList
    set end of dockAppsList to |file-label| of |tile-data| of thisRecord
end repeat

return dockAppsList

这篇关于Applescript 可以列出放置在 Dock 中的所有应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 01:29