When you correctly implement EntityPropertyQuery on an AppEntity, Shortcuts will expose a "Find Entity" action that calls into entities(matching:mode:sortedBy:limit:). This is demoed in the "Dive into App Intents" session and works as expected.
However, with this action, you can change the "All Entity" input to a list variable which changes the action text from "Find All Entity" to "Filter Entity where" still giving you the same filter, sort and limit options. This appears to work as expected too. But, what's unexpected is that this filter action does not appear to call any method on my AppEntity code. It doesn't call entities(matching:mode:sortedBy:limit:). One would think there would need to be a filter(entities:matching:mode:sortedBy:limit:) to implement this functionality. But Shortcut just seems to do it all on it's own. I'm mostly wondering, how is this even working?
Here's some example code:
import AppIntents
let books = [
BookEntity(id: 0, title: "A Family Affair"),
BookEntity(id: 1, title: "Atlas of the Heart"),
BookEntity(id: 2, title: "Atomic Habits"),
BookEntity(id: 3, title: "Memphis"),
BookEntity(id: 4, title: "Run Rose Run"),
BookEntity(id: 5, title: "The Maid"),
BookEntity(id: 6, title: "The Match"),
BookEntity(id: 7, title: "Where the Crawdads Sing"),
]
struct BookEntity: AppEntity, Identifiable {
static var typeDisplayRepresentation: TypeDisplayRepresentation = "Book"
var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(title)") }
static var defaultQuery = BookQuery()
var id: Int
@Property(title: "Title")
var title: String
init(id: Int, title: String) {
self.id = id
self.title = title
}
}
struct BookQuery: EntityQuery {
func entities(for identifiers: [Int]) async throws -> [BookEntity] {
return identifiers.map { id in books[id] }
}
}
extension BookQuery: EntityPropertyQuery {
static var properties = QueryProperties {
Property(\BookEntity.$title) {
EqualToComparator { str in { book in book.title == str } }
ContainsComparator { str in { book in book.title.contains(str) } }
}
}
static var sortingOptions = SortingOptions {
SortableBy(\BookEntity.$title)
}
func entities(
matching comparators: [(BookEntity) -> Bool],
mode: ComparatorMode,
sortedBy: [Sort<BookEntity>],
limit: Int?
) async throws -> [BookEntity] {
books.filter { book in comparators.allSatisfy { comparator in comparator(book) } }
}
}
The example Shortcut first invokes entities(matching:mode:sortedBy:limit:) with comparators=[], sortedBy=[], limit=nil to fetch all Book entities. Next the filter step correctly applies the title contains filter but never calls entities(matching:mode:sortedBy:limit:) or even the body of the ContainsComparator. But the output is correctly filtered.
Automation & Scripting
RSS for tagLearn about scripting languages and automation frameworks available on the platform to automate repetitive tasks.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I’ve developed an automation and shortcut using the iPhone Shortcuts app in IOS 18, something that hasn’t been done before. With support from Apple’s customer service, I was encouraged to bring this idea to life.
The automation’s purpose is to open a specified iOS app, move it to the background, and use a txt database in Folders to ensure uninterrupted data flow and continuous connectivity—especially useful for health apps where wearable devices need consistent, uninterrupted operation and monitoring (e.g., doctor tracking or wearable device connectivity). I would like to share the Automation and the Shortcut with the community.
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags:
Health and Fitness
Scripting
Shortcuts
I have a VBScript routine to print envelopes by automating Word. This works just fine.
Now I'm trying to do the same thing with AppleScript, also using the Word application. Here is what I have so far:
set recipientAddress to text returned of (display dialog "Enter the recipient's address:" default answer "")
-- Prompt for recipient city, state, and zip
set recipientCityStateZip to text returned of (display dialog "Enter the recipient's city, state, and zip:" default answer "")
-- Combine all address parts into a full address
set fullAddress to recipientName & return & recipientAddress & return & recipientCityStateZip
-- Create a new Word document and print the envelope
set dialogResult to display dialog "To print envelope for:" & return & return & recipientName & return & recipientAddress & return & recipientCityStateZip & return & return & "Center envelope upside-down in printer with flap on left" & return & return & "Continue?" buttons {"Yes", "No"} default button 2 with icon caution
if button returned of dialogResult is "Yes" then
tell application "Microsoft Word"
set wdDoc to make new document
-- Print the envelope with the collected recipient address and hard-coded return address
-- wdDoc's print out envelope(address:fullAddress, returnAddress:returnAddress)
-- Close the document without saving
close wdDoc saving no
end tell
end if
What does NOT work is the commented line near the end of the script which starts with -- wdDoc's print out envelope...
Either I am doing it wrong, or Word for Mac can't be automated that way. Can anyone help with this script, or at least suggest a different method to print an envelope on demand?
Thanks...
Hello,
There is a new shortcut recently in iOS shortcuts called "Open [Pass or Card]". It looks to take in a [Pass or Card] type, however I'd like to program it with a shortcut to dynamically select a card, and I noticed it works with strings, such as "BofA Customized Cash Rewards".
Would there be a list of possible strings for supported cards and/or passes that I could pass in for this shortcut?
Is there a way for my app to know that a phone number has just been messaged to or a call to 911 just started? Or SOS has just been executed by the user?
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags:
iOS
SMS and Call Reporting
CallKit
Hello.
I have NFC tags that I scan before walking my dog, that set off a list of shortcuts.
The shortcuts have been failing the last couple of weeks but were fine before that. seems to be a problem with linking to starting a walk in apple watch workouts?!
I have the latest iOS 18 public beta running (18.1) and watchOS 11.0.1
I often need to remotely control a Mac that has the Remote Desktop application running on it. Thus I need to create a script to kill it remotely. The following command gives me the process number (PID) on the remote machine when logged in via SSH. What I need to know is how to pass that number to kill -3 to quit it with one command, bad thing can happen if you make a typo on PID
ps -ax | grep "Remote Desktop.app" | grep -v grep | awk '{print $1}'
Hello,
We are working on automating some processes for our mac virtual machines pool, and one of the things we are looking for is where we can download various different versions of macOS.
When going to the download section of the apple dev portal, it only gives a download link of the latest macOS. Is there no way to obtain download URLs for previous macOS versions as well? For instance, we are trying to validate our automation scripts against Sonoma macOS so we are looking for the download URL , to put in our scripts , or to manually download the file ourselves.
Thanks!
Hello.
tell application "Microsoft Excel"
Where can I find complete help for all Excel commands?
trying to quit 2 apps and launch a 3rd.
3 individual Automator apps work by themselves fine.
But can't get them to "open an app" from Calendar at a specified time.
Tried building an Apple Script. Same issue.
Here's the Automator app.
**
tell application "Jellyfin Media Player" to quit
delay 1
tell application "Jellyfin server 10.10.1" to quit
delay 1
tell application "EmbyServer 4.8.10" to activate**
any help on what I'm doing wrong?
seems simple enough.
Both Automator and Script Ed have "full disk access" and "Accessibility"
I have created swift command line project and i have added logic to executing apple script using NSAppleScript. That will launch Microsoft Excel file
I am launching this swift command line executable from java using process launch.
3)This is not prompting me. It is throwing exception "Not authorized to send Apple events to Microsoft Excel."
I have already tried out this option
Added info.plist with NSAppleEventsUsageDescription
Added entitlement with com.apple.security.automation.apple-events to true
In packages i have selected this entitlement
i have select the bundle identifier , team and signing certificate "Development" and automatically manage signing.
can you please suggest what could i missed ?
Hi! Im attempting to make a spotify to apple playlist converter and to do so am using the Catalog search functionality of the api. My question is, is there anyway to convert these songs to apple music urls (or ids) that does not spam api calls. I know you can batch catalog searches if you have apple music song ids, but I obviously dont have that since the song was shared from spotify. Any ideas/help is appreciated!
Hello everyone,
I would like to dictate a text with Shortcuts and then send it to one of two e-mail addresses (private or business).
I would like to be able to select one of two email addresses.
Unfortunately, I am not able to pass an email address as a parameter to the Send email function. Is it possible to do this?
I'm new to apple and I'm all but not a programmer. So take pity on me :)
Best, Niko
I have:
an Automator workflow saved as an application "workflow.app"
an Apple Script saved as an application "script.app"
a PDF file residing on Desktop "test.pdf"
How do I launch workflow.app and pass test.pdf as the input for workflow from inside script.app?
I have been trying to accept drops from Apple Mail which do supply data with type identifiers : com.apple.mail.email
The problem is that even though the drop says it does contain items for com.apple.mail.email it does provide the items for com.apple.mail.email.
Mail dropped from Microsoft Outlook however confirms to the protocols and returns the items for com.apple.mail.email
Is this a known issue with Apple Mail and is there are reason for what seems to be a non-compliance to it own standards in Apple Mail?
I have a bunch of images sized 540px on the long side (some portrait, some landscape). The other side could be any size, but will be less than 540. There are no square images.
I want to be able to choose a folder containing the images, and want the script to do the following for each image:
Place it at the center of the current page of the active indesign document. Scrape the filename from the image (without the extension), apply the pre-existing Paragraph Style 'Caption' to the text, and center the text 36 points (not pixels) below the image.
Group the image and the text.
Then create a frame with white fill, 540x600 pixels in size, send it to back, center it with the group created above, and group them.
I've been pulling my hair out. Just can't get it to work.
I would like to run an automation that sends a text message to my personal phone whenever my work phone receives a text message. In the “Message Contains” field of the message automation, an input is required. I put in a space, but that won’t work if someone sends me a one word text. Any suggestions?
Topic:
App & System Services
SubTopic:
Automation & Scripting
I am needing to add/delete shortcuts in our app without using the Add to Siri button. But have been stymied at every turn. The most recent example is some code that uses an "AppShortcutCenter" call, supposedly added in iOS 17. But there is no such thing as that which I can find. What gives, and what's needed to do custom shortcuts on demand programmatically?
I'm trying to use Image Events instead of Photoshop to manipulate a bunch of images.
I need to extend the canvas and have the padding be white. I've tried
pad theImage to dimensions {545, 545} with pad color {65535, 65535, 65535}
But that does nothing. If I remove the 'with pad colour...' part, it works but the pad defaults to black. I've looked everywhere, but there doesn't seem to be a solution.
Is there one?
Hello everyone,
I would like to use AppleScript to transform a .csv file.
To make things easier to understand, I'm attaching two files:
1- The original file in csv format
2- The file as I'd like it to look after I've run it through the script.
Here are the steps involved
1-Open the file in numbers (Note: the file is located in the download folder).
2-Delete the first 6 lines
3-Delete all font styles and cell colors
4-Combine all cells in the nature of operation column of the same operation belonging to the same date in the first cell of the operation, deleting all spaces in the text is not necessary for each operation.
5- Delete all empty lines.
I hope I've made my request clear.
If any of you have the knowledge to do this, if it can be done at all, I'd be very grateful for their help in writing the script.
Thank you in advance.
1.csv
2.csv