photos-applescript-banner
•
OS X AUTOMATION
AUTOMATOR
IWORK AUTOMATION
•

Photos Extras Suite

The Photos Extras Suite contain useful commands not found in the the other suites.

show location in Maps v  : (Available in Photos Utilities script library 1.1) Show location pins in the Maps application for each of the specified media items. By default, the title of the media will be used as the pin description. If the media item has no title, the filename will be used instead.

show location in Maps

for object reference(s) : References to the media item(s) whose locations are to be displayed

[ map type integer ] : A number indicating the type of map to display. 0 = standard, 1 = satelite, 2 = hybrid (satelite and traffic)

→ list of media items : A list of the media items provided as input

Script Examples

The following scripts demonstrate the use of the commands in the Photos Export Suite.

Show Location in Maps
  
01use script "Photos Utilities"
02 
03tell application "Photos"
04 set theseMediaItems to get the selection
05 show location in Maps for theseMediaItems map type 1
06end tell
map-locations

And here is a script you can use to add a screen capture image of the Maps window to a new slide in Keynote:

Add Image of Maps Window to Keynote
  
01tell application "Maps"
02 activate
03 if the (count of windows) is 0 then error number -128
04 set thisID to id of window 1
05end tell
06tell current application
07 set pathToPicturesFolder to the POSIX path of (path to the pictures folder)
08 set windowCaptureFilePath to pathToPicturesFolder & "map-window.png"
09 -- set the capture to begin after 3 seconds and to capture just the window (no shadow)
10 set commandString to "screencapture" & space & "-T" & space & 3 & space & "-ao" & space & "-l" & space & thisID & space & (quoted form of windowCaptureFilePath)
11 do shell script commandString
12end tell
13tell application "Keynote"
14 activate
15 if not (exists document 1) then
16 set thisDocument to make new document
17 else if the (count of documents) is not 1 then
18 set documentNames to the name of every document
19 set chosenDocument to (choose from list documentNames with prompt "Pick the document to add the image to:")
20 if chosenDocument is false then error number -128
21 set chosenDocument to chosenDocument as string
22 set thisDocument to the first document whose name is chosenDocument
23 else
24 set thisDocument to document 1
25 end if
26 tell thisDocument
27 set newSlide to make new slide with properties {base slide:master slide "Blank"}
28 tell newSlide
29 make new image with properties {file:(windowCaptureFilePath as POSIX file)}
30 end tell
31 end tell
32end tell
new-slide-with-map

The show location in Maps command used in a Dictation Workflow:

Your browser does not support the video tag.

NEXT TOPIC: Scripting Overview

TOPICS

  • Automator Overview

  • Scripting Overview
  • Photos Script Library
  • Photos Utility Suite
  • Photos Export Suite
  • Photos Extras Suite

ABOUT SCRIPT LIBRARY

For those interested in creating and writing scripts and script libraries, the Photos Utilities Script Library is written in AppleScriptObj-C, a dynamic fusion of the AppleScript and Objective-C programming languages. The source code of the library can be viewed in a script editing application.

Comprehensive 3rd-party documentation and tools for writing and deploying AppleScriptObj-C applications, scripts, and script libraries are available from Myriad Communications.

LINK TO MYRIAD COMMUNICATIONS WEBSITE

DISCLAIMER

THIS WEBSITE IS NOT HOSTED BY APPLE INC.

Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. PHOTOSAUTOMATION.COM assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. PHOTOSAUTOMATION.COM provides this only as a convenience to our users. PHOTOSAUTOMATION.COM has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and PHOTOSAUTOMATION.COM assumes no responsibility in this regard. Please understand that a third-party site is independent from PHOTOSAUTOMATION.COM and that PHOTOSAUTOMATION.COM has no control over the content on that website. Please contact the vendor for additional information.