• 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: Can't get the change download folder in Safari script to work - ui scripting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't get the change download folder in Safari script to work - ui scripting


  • Subject: Re: Can't get the change download folder in Safari script to work - ui scripting
  • From: Tommy Bollman <email@hidden>
  • Date: Sun, 13 Mar 2011 22:01:09 +0100

Hello Luther and thanks for the effort.

I agree totally with you about UIscripting :-). But I know that Yvan's solution will work once I have translated it (from French to Norwegian element titles ).

It's just that I can't kick Safari to read in the preferences/default values without restarting it.
That might not allways be an option, since I may have 3 or four sets of windows, which
turns into a mess even with the "Restore Session" plugin. -I loose "state" when that happens.

Do any of you manage to make Safari notice that the preferences / default has changed, or is that
only with Safari (5.04) and SL 10.6.6 - at my machine. I really have to quit Safari in order to
make changes in defaults and preferences take effect as it is today, and then I think Yvan's solution is the most "right" for me, UIScripting or not.

Tommy

Den 13. mars 2011 kl. 20.24 skrev Luther Fuller:

> On Mar 13, 2011, at 10:30 AM, Tommy Bollman wrote:
>
>> Hello. I have som problems with Getting the  block marked #!? to work,
>> I'm using Safari v.5.03 and I think that the layaout of the ui-elements has changed some.
>
> Never use UI scripting unless you absolutely, positively have to.
>
> I just could not resist finding a non-GUI solution to this.
> The location of Safari's downloads folder is stored in Safari's
> preference file "com.apple.Safari.plist" in the key "DownloadsPath".
>
> All you have to do is write a new value to this key. Here's the script ...
>
> on run
> 	set DLFolderAlias to my getDownloadFolder()
> 	my setSafariDLFolder(DLFolderAlias)
> 	beep
> end run --------------------
>
> on getDownloadFolder()
> 	set pText to "Choose a new download folder for Safari ..."
> 	set DLFolder to choose folder with prompt pText default location (path to desktop) -- error -128 on cancel
> 	return DLFolder -- an alias
> end getDownloadFolder --------------
>
> on setSafariDLFolder(folderAlias)
> 	set folderPath to (POSIX path of folderAlias)
> 	set prefsFolder to (path to preferences folder from user domain)
> 	tell application "Finder" to set prefsFile to (file "com.apple.Safari.plist" of prefsFolder) as alias
> 	tell application "System Events" to set infoRecord to value of property list file (prefsFile as text) -- READ
> 	set infoRecord to {DownloadsPath:folderPath} & infoRecord -- MODIFY
> 	tell application "System Events" to set value of property list file (prefsFile as text) to infoRecord -- WRITE
> end setSafariDLFolder ---------------
>
> And, yes, I did try it and it worked.
>
> _______________________________________________
> 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

Best regards



Tommy Bollman
--------------------------------------------------------------------------------------------------
Mollison's Bureaucracy Hypothesis:
	If an idea can survive a bureaucratic review
	and be implemented it wasn't worth doing.

 _______________________________________________
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: Can't get the change download folder in Safari script to work - ui scripting
      • From: KOENIG Yvan <email@hidden>
References: 
 >Can't get the change download folder in Safari script to work - ui scripting (From: Tommy Bollman <email@hidden>)
 >Re: Can't get the change download folder in Safari script to work - ui scripting (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: Can't get the change download folder in Safari script to work - ui scripting
  • Next by Date: Re: Can't get the change download folder in Safari script to work - ui scripting
  • Previous by thread: Re: Can't get the change download folder in Safari script to work - ui scripting
  • Next by thread: Re: Can't get the change download folder in Safari script to work - ui scripting
  • Index(es):
    • Date
    • Thread