• 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: Setting a .plist value?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting a .plist value?


  • Subject: Re: Setting a .plist value?
  • From: Brian Christmas <email@hidden>
  • Date: Sun, 07 Feb 2016 10:18:51 +1100

Thanks David

Your code certainly does work. I’ve worked 15 hours per day for the last 4 days, and in my (delirious) state, I forgot to add an on error trap. Turned out my perennial problem with Accessibility was stopping my app from accessing your script.

I’ve fixed the problem, and now my app, using yours and Shanes guidance, creates a fixed icon even when the previous icon has been dragged off the Dock.

Regards

Santa

Code is (for posterity)…

on installDockIcon()
try


set theInfo to (current application's NSUserDefaults's alloc()'s init()'s persistentDomainForName:"com.apple.dock") as record
set theMatches to get theInfo's |persistent-apps|
tell current application to say (count of theMatches) -- returns '61'
set MatchingList to {}
set x to 0
repeat with thisRecord in theMatches
set x to x + 1
set theTestMatch to get thisRecord's |tile-data|
set theMMMatch to theTestMatch's |file-label|
if theMMMatch is "Mail Manager" then
set end of MatchingList to item x of theMatches
end if
end repeat
set existsMMDockIcon to my installDockItemsTest()
if (count of MatchingList) = 0 or not existsMMDockIcon then
do shell script ("sleep 0.2")
try
set item_path to ((path to applications folder) & "Mail Manager:Mail Manager.app" as text)  end try
do shell script ("sleep 0.2")
try
set item_path to POSIX path of item_path
do shell script "defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>" & item_path & "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'"
tell application "Dock" to quit
end try
end if
set theInfo to (current application's NSUserDefaults's alloc()'s init()'s persistentDomainForName:"com.apple.dock") as record
end try
end installDockIcon


on installDockItemsTest()
set x to 0
try
tell application "System Events"
tell process "Dock"
set t to (title of UI elements of list 1)
repeat with theTest in t
if theTest as text = "Mail Manager" then set x to x + 1
end repeat
end tell
end tell
end try
return (x > 0)
end installDockItemsTest



 _______________________________________________
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

  • Follow-Ups:
    • Re: Setting a .plist value?
      • From: Shane Stanley <email@hidden>
References: 
 >Re: Setting a .plist value? (From: Brian Christmas <email@hidden>)
 >Fwd: Setting a .plist value? (From: Brian Christmas <email@hidden>)
 >Re: Setting a .plist value? (From: David Gregg <email@hidden>)

  • Prev by Date: Re: Setting a .plist value?
  • Next by Date: Re: Setting a .plist value?
  • Previous by thread: Re: Setting a .plist value?
  • Next by thread: Re: Setting a .plist value?
  • Index(es):
    • Date
    • Thread