• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: make a new dock dock item using AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make a new dock dock item using AppleScript


  • Subject: Re: make a new dock dock item using AppleScript
  • From: Luther Fuller <email@hidden>
  • Date: Fri, 09 Oct 2009 10:44:34 -0500

On Oct 4, 2009, at 1:39 AM, Ronald Hofmann wrote:
I want to create a new dock item from an existing application using AppleScript.
Just the same way like dragging the app to the dock.

Has somebody done this before?

I have written an application that will properly install a folder in the Dock as a menu. I did it by reverse engineering the array "persistent-others" in the preference file "com.apple.dock.plist". I have not tried this with an application, so I don't know how to do this, but reverse engineering the array "persistent-apps" ought to yield something useful.

Here's the handler I used ...

on addDockMenu(folderAlias)
-- 1 construct the |file-data| record
set folderPath to (POSIX path of folderAlias)
if (last character of folderPath) = "/" then
set folderPath to (text 1 thru -2 of folderPath)
end if
set newFileData to {|_CFURLString|:folderPath, |_CFURLStringType|:0}


--2 construct the |tile-data| record
tell application "Finder" to name of folderAlias
set newTileData to {arrangement:0, displayas:1, |file-data|:newFileData, |file-label|:the result, |file-type|:2, showas:3}


-- 3 construct the newMenuFolderItem record
set newMenuFolderItem to {|tile-data|:newTileData, |tile-type|:"directory-tile"}


-- 4 write to Dock preference file
set prefsFile to (((path to preferences from user domain) as text) & "com.apple.dock.plist") as alias
tell application "System Events"
set dockPath to (prefsFile as text)
set dockRec to (value of property list file dockPath)
set |persistent-others| of dockRec to ((|persistent-others| of dockRec) & {newMenuFolderItem})
set (value of property list file dockPath) to dockRec
end tell
tell application "Dock" to quit
end addDockMenu -----------------------------

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >make a new dock dock item using AppleScript (From: Ronald Hofmann <email@hidden>)

  • Prev by Date: not all dropped items make it
  • Next by Date: Re: not all dropped items make it
  • Previous by thread: Re: make a new dock dock item using AppleScript
  • Next by thread: Quitting Scripts
  • Index(es):
    • Date
    • Thread