将项目添加到Finder /保存对话框侧边栏 [英] Add an item to the Finder/Save dialog sidebar

查看:170
本文介绍了将项目添加到Finder /保存对话框侧边栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个脚本,用户在操作系统上登录访客帐户,并提示他们的网络凭据,以便挂载其网络主文件夹(虽然他们受益于在本地用户文件夹中工作)。



由于客户端文件夹在用户注销时被删除,因此我想阻止他们保存任何内容。我想将Finder和打开/保存侧边列表(例如桌面,用户名,文档等)中的项目替换为将保存到其网络主文件夹中的项目。



使用AppleScript或Cocoa API可以做到这一点,还是需要修改plist并重新启动Finder? [Ack。查看〜/ Library / Preferences / com.apple.sidebars.plist,它是不是很清楚如何填充它。]



类似问题: / p>

AppleScript:添加已安装




  • 建议使用fstab;此代码很可能作为用户运行,并且真正的自动安装在这一点上太晚了。



如何以编程方式将文件夹图标放在Finder上侧栏,因为您必须为文件夹使用自定义图标




  • 说没有Cocoa API,您可以使用仅在单个头文件中记录的碳样式LSSharedFileList API。

  • 有人知道一些示例代码可以向Finder侧栏添加项目吗?


解决方案

同事提出了使用applescript的方法:

 告诉应用程序Finder
activate
- 在Finder中的侧栏上选择所需的路径
选择文件夹
通过应用程序系统事件
- Command-T将文档文件夹添加到边栏
keystroket使用命令down
end tell
end tell


I'm working on a script where a user logs into a guest account on OS and is prompted for their network credentials in order to mount their network home folder (while they benefit from working on a local user folder).

As the guest folder is deleted when users log out, I want to discourage them from saving anything there. I would like to replace the items on the Finder and Open/Save sidebar lists (such as "Desktop", username, "Documents", etc) with ones that would save into their network home folder.

It is possible to do this using AppleScript or Cocoa APIs, or do I need to modify a plist and restart the Finder? [Ack. Looking into ~/Library/Preferences/com.apple.sidebars.plist, it isn't at all clear how I'd populate it.]

Similar Questions:

AppleScript: adding mounted folder to Finder Sidebar?

  • suggests using fstab; this code will most likely run as a user and really, automounting at that point would be too late.

How do you programmatically put folder icons on the Finder sidebar, given that you have to use a custom icon for the folder?

  • Says there is no Cocoa API, but that you can use a carbon-style LSSharedFileList API that is only documented in a single header file.
  • Does anyone know of some example code to add an item to the Finder sidebar?

解决方案

A co-worker came up with this method that uses applescript:

tell application "Finder"
    activate
    -- Select the path you want on the sidebar in the Finder
    select folder "Preferences" of folder "Library" of (path to home folder)
    tell application "System Events"
        -- Command-T adds the Documents Folder to the sidebar
        keystroke "t" using command down
    end tell
end tell

这篇关于将项目添加到Finder /保存对话框侧边栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆