Re: AppleScript-Users Digest, Vol 9, Issue 331
Re: AppleScript-Users Digest, Vol 9, Issue 331
- Subject: Re: AppleScript-Users Digest, Vol 9, Issue 331
- From: Bennett Hart <email@hidden>
- Date: Mon, 27 Aug 2012 21:15:48 -0500
I'm going to go to bed with headphones on. Soon.
He made me grumpy. I wish Elvis would take him on for me.
On Aug 27, 2012, at 9:07 PM, email@hidden wrote:
> Send AppleScript-Users mailing list submissions to
> email@hidden
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.apple.com/mailman/listinfo/applescript-users
> or, via email, send a message with subject or body 'help' to
> email@hidden
>
> You can reach the person managing the list at
> email@hidden
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of AppleScript-Users digest..."
>
>
> Today's Topics:
>
> 1. Re: OS X 10.8 Security & Applescripts - "unidentified
> developer" (Shane Stanley)
> 2. Re: InDesign CS6 Document Preferences (Shane Stanley)
> 3. Previous APOD Page (Christopher Stone)
> 4. Re: Previous APOD Page (Robert Poland)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 28 Aug 2012 08:46:09 +1000
> From: Shane Stanley <email@hidden>
> To: Applescript Users <email@hidden>
> Subject: Re: OS X 10.8 Security & Applescripts - "unidentified
> developer"
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=us-ascii
>
> On 28/08/2012, at 6:02 AM, Luther Fuller <email@hidden> wrote:
>
>> This raises some questions:
>
> And they're all answered on Apple's Web site: <http://www.apple.com/osx/what-is/security.html>
>
>> 1. I don't know what the default is for "Allow applications downloaded from:",
>> but I suspect it is not "Anywhere". Isn't this too strong, especially
>> with no "Open Anyway" button ?
>
> "...the default option, which allows you to download apps from the Mac App Store as well as those signed with a Developer ID."
>
>> 2. What about an identified developer (one who has purchased an Apple
>> certificate) but who does not distribute via mac App Store ?
>
> That's what "signed with a Developer ID" means.
>
>> 3. How are self-signed certificates handled ?
>
> They don't match the above, so they're the same as unsigned apps.
>
> --
> Shane Stanley <email@hidden>
> 'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 28 Aug 2012 08:54:19 +1000
> From: Shane Stanley <email@hidden>
> To: AS users <email@hidden>
> Subject: Re: InDesign CS6 Document Preferences
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset="utf-8"
>
> On 28/08/2012, at 7:02 AM, "Nielsen, Karen S. (Schmidt)" <email@hidden> wrote:
>
>> tell document myDoc
>
> That line suggests myDoc is the name of a document -- a string.
>
>> tell document preferences of myDoc
>
> If myDoc is a string, that won't work -- you will get the error you describe. Change it to:
>
> tell document preferences of document myDoc
>
> --
> Shane Stanley <email@hidden>
> 'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <https://lists.apple.com/mailman/private/applescript-users/attachments/20120828/4325b5c8/attachment.html>
>
> ------------------------------
>
> Message: 3
> Date: Mon, 27 Aug 2012 20:06:57 -0500
> From: Christopher Stone <email@hidden>
> To: Applescript Users List <email@hidden>
> Subject: Previous APOD Page
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=us-ascii
>
> Hey Folks,
>
> Like many people I enjoy the APOD, and also like many people I often forget to visit it daily.
>
> Enter Applescript.
>
> This script will jump backwards one day from the currently viewed APOD page, so you can quickly review what you missed.
>
> I run mine via a keyboard shortcut with FastScripts.
>
> --
> Best Regards,
> Chris
>
> ------------------------------------------------------------------------------------------------
> # Safari
> # Go to previous APOD page
> # APOD: http://apod.nasa.gov/apod/
> ------------------------------------------------------------------------------------------------
> try
>
> tell application "Safari"
> tell front document
> set pageURL to quoted form of (get URL)
> set urlPath to do shell script "sed -E 's|[^/]+$||' <<< " & pageURL
> set src to quoted form of (do shell script "tr '\\r' '\\n' <<< " & (quoted form of (get source)) without altering line endings)
> set previousApodURL to urlPath & (do shell script "echo " & src & " | sed -n '/></p' | sed -E 's/[^\"]+\"([^\"]+).+/\\1/'")
> set URL to previousApodURL
> end tell
> end tell
>
> on error eMsg number eNum
> set {c, s} to {return, "------------------------------------------"}
> set e to s & c & "Error: " & eMsg & c & s & c & "Error Number: " & eNum & c & s
> beep
> set dDlg to display dialog e buttons {"Cancel", "Copy", "OK"} default button "OK"
> if button returned of dDlg = "Copy" then
> set the clipboard to e
> end if
> end try
> ------------------------------------------------------------------------------------------------
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Mon, 27 Aug 2012 20:07:24 -0600
> From: Robert Poland <email@hidden>
> To: Christopher Stone <email@hidden>
> Cc: Applescript Users List <email@hidden>
> Subject: Re: Previous APOD Page
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset="windows-1252"
>
>
> On Aug 27, 2012, at 7:06 PM, Christopher Stone <email@hidden> wrote:
>
>> Hey Folks,
>>
>> Like many people I enjoy the APOD, and also like many people I often forget to visit it daily.
>>
>> Enter Applescript.
>>
>> This script will jump backwards one day from the currently viewed APOD page, so you can quickly review what you missed.
>>
>> I run mine via a keyboard shortcut with FastScripts.
>>
>> --
>> Best Regards,
>> Chris
>
> Chris,
>
> I run this script every morning via launched;
>
> (*
> new AutoAPOD - 10/1/04 - from Johnny AppleScript <email@hidden> 11/26/04 - add local to variables 1/23/05 - exit to AutoApod Preferences on error 6/2/05 - removed "aypod image already downloaded" anouncement 4/20/2010 - Remove AutoAPOD link
> *)
>
> on run
> main()
> end run
>
> on main()
> try -- exit gracefully if script won't run
> (*
> local a, APOD, apodEXT, apodName, archiveEXT, b, curAPOD, d
> local dateTAG, destinationFolder, dfExists, dn, downloadOption, errMsg
> local fileName, filePath, flag, folderName, getImage, imageEXT, imageURL, leadTAG, leadTAG1
> local leadTAG2, m, mn, pFlag, rootURL, test, ThePicture, trailingTAG, trailingTAG1
> local trailingTAG2, y, yn
> *)
> set test to false -- false disables dialogs
> set {y, m, d} to {year, month, day} of (current date) --> date "Sunday, September 26, 2004 7:45:07 PM"
> set d to d as text
> if number of characters in d < 2 then set d to "0" & d as string -- good catch, Bob; I should have predicted this
> set flag to quoted form of (y & " " & m & " " & d as string) --> "2004 September 26"
> set yn to y as text --> "2004"
> set yn to characters -2 thru -1 in yn as string --> "04"
> set mn to (m as number) as text --> "9"
> if number of characters in mn < 2 then set mn to "0" & mn --> "09"
> set dn to d as text --> ex.: "6"
> if number of characters in dn < 2 then set dn to "0" & dn --> ex.: "06"
> set pFlag to yn & mn --> "0409"
> set dateTAG to pFlag & dn --> "040926"
> set rootURL to "http://apod.nasa.gov/apod/"
> set archiveEXT to "archivepix.html"
> -- http://apod.nasa.gov/apod/archivepix.html - 2004 September 26
> try
> set APOD to do shell script "curl " & rootURL & archiveEXT & " | grep " & flag
> on error
> -- if test then
> display dialog "1, APOD Image Retriever: " & return & rootURL & return & "is currently unavailable. Please try again later." buttons {"Poopy"} default button 1 giving up after 5 with icon 2
> return
> end try
> set leadTAG to "<a href=\""
> set trailingTAG to "\">"
> set leadTAG1 to (offset of leadTAG in APOD)
> set trailingTAG1 to (offset of trailingTAG in APOD)
> set apodEXT to characters (leadTAG1 + 9) thru (trailingTAG1 - 1) in APOD as string
> -- set apodName to characters (trailingTAG1 + 2) thru -9 in APOD as string
> try
> set curAPOD to do shell script "curl " & rootURL & apodEXT & " | grep href | grep jpg | grep " & pFlag -- Doh! What if it's a GIF?
> on error errMsg
> try
> set curAPOD to do shell script "curl " & rootURL & apodEXT & " | grep href | grep gif | grep " & pFlag
> -- this method is bound to fail. We need a better analysis; can you think of one?
> on error
> if test then display dialog "2, APOD Image Retriever: locate daily image failed: " & errMsg with icon 0 -- giving up after 15
> (* -- AutoAPOD not available for Snow Leopard
> tell application "System Events"
> tell application "System Preferences" to activate
> tell process "System Preferences"
> click menu item "AutoAPOD" of menu "View" of menu bar item "View" of menu bar 1
> tell radio button 1 of tab group 1 of window 1 to if value is 0 then click
> click button 1 of tab group 1 of window 1 -- "Fetch Now"
> delay 1
> click button 2 of tab group 1 of window 1 -- "Set As Deskop"
> delay 1
> end tell
> return
> end tell
> *)
> end try
> end try
> set leadTAG2 to (offset of leadTAG in curAPOD) -- using a different flag length than above
> set trailingTAG2 to (offset of trailingTAG in curAPOD) -- using a different flag length than above
> set imageEXT to characters (leadTAG2 + 9) thru (trailingTAG2 - 1) in curAPOD as string
> set filename to reverse of every character of imageEXT as string
> set filename to reverse of every character of (characters 1 thru ((offset of "/" in filename) - 1) in filename as string) as string
> set filename to dateTAG & "-" & filename -- let's add today's date string to the prefix for our own archives
> set imageURL to rootURL & imageEXT
> set folderName to "APOD ƒ"
> set destinationFolder to ((path to pictures folder) & folderName & ":" as string) -- we'll need to use this path more than once, so let's give it a unique variable name
> -- 040928 added the 'APOD ƒ' folder to the destination path string; be sure this folder actually exists, or the script will fail
> tell application "Finder" to set dfExists to (exists folder destinationFolder)
> if dfExists is false then tell application "Finder" to make new folder at (path to pictures folder) with properties {name:folderName}
> set filePath to POSIX path of destinationFolder -- here's the first use; we need a UNIX-style path string; i.e., /Users/bob/Pictures/
> set ThePicture to ((destinationFolder & filename) as string) -- here's the second use; we need and HFS-style path string; i.e., :Users:bob:Pictures:file_name
> tell application "Finder" to set downloadOption to (exists file ThePicture)
> if downloadOption is false then
> set getImage to "curl " & imageURL & " -o " & "\"" & filePath & filename & "\""
> -- set {a, b} to {"Thanks", "Download"}
> -- set dlOption to button returned of (display dialog "Today's image is " & return & "'" & apodName & "'" & return & return & imageURL buttons {a, b} default button 2 with icon 1)
> -- if dlOption is b then
> try
> do shell script getImage
> -- delay 10 -- need an appropriate delay here - - if using curl; not required with URL Access Scripting - - before setting a picture to desktop background that may still be downloading; might be best to either run a different script, or run an idle handler to allow enough safe time for d/l of very large images or if there is an image d/l failure. Don't forget about using try blocks.
> -- tell application "URL Access Scripting" to download imageURL to ThePicture -- unlike curl, this method will stop the rest of the script until the d/l is completed; no additional delay command is required.
> on error errMsg
> if test then display dialog "3, APOD Image Retriever: download failed: " & errMsg with icon 0 -- giving up after 15
> end try
> -- set desktopSet to button returned of (display dialog "Set image as desktop?" buttons {"No", "Yes"} default button 1 with icon 1 giving up after 10)
> try
> set ThePicture to ThePicture as alias -- need to make a file path string into an object Finder can recognize
> -- if desktopSet is "Yes" then
> tell application "Finder" to set desktop picture to ThePicture
> on error errMsg
> if test then display dialog "5, " & return & errMsg with icon 0 -- giving up after 15
> end try
> -- end if
> else
> ignoring application responses
> # say "autopod im age already downloaded"
> end ignoring
> end if
> on error errMsg
> end try
> return
> end main
>
> Robert Poland - Fort Collins, CO
>
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <https://lists.apple.com/mailman/private/applescript-users/attachments/20120827/f694b5ea/attachment.html>
>
> ------------------------------
>
> _______________________________________________
> AppleScript-Users mailing list
> email@hidden
> https://lists.apple.com/mailman/listinfo/applescript-users
>
> End of AppleScript-Users Digest, Vol 9, Issue 331
> *************************************************
_______________________________________________
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