Automation & Scripting

RSS for tag

Learn about scripting languages and automation frameworks available on the platform to automate repetitive tasks.

Automation & Scripting Documentation

Posts under Automation & Scripting subtopic

Post

Replies

Boosts

Views

Activity

Shortcuts: How to add text to a file name
Hi there, Does anyone know how to modify this Image compressor Shortcut https://www.icloud.com/shortcuts/e13d8013598f4f33830386a956a163dd so that the image it creates has the original file name + “-pressed”? Eg “Image_123” becomes “Image_123-pressed” I know of the action ‘Rename file’ but can’t make it work. The shortcut does batch processing of images if that makes any difference. Any help much appreciated:)
0
0
196
Jan ’26
App Intents with Custom Automation/Triggers
Currently, we are developing an all-in-one DualSense utility for macOS. We are exploring how to integrate shortcuts into our app. Our vision is to have the user use the native Shortcuts app to choose the controller buttons that should trigger the shortcut action, such as opening Steam, turning on audio haptics, and more. As we explore this approach, we want to see whether we need to build the UI in our app to set the triggers or can we do this inside of Shortcuts? Can button presses recorded by our app trigger shortcuts? Can those button inputs be customized inside of Shortcuts or should we develop it into our app? And if we have it in our app, can our app see, select, and trigger shortcuts?
0
0
268
Jan ’26
App Intents: String array parameter value clears immediately in Shortcuts editor
Hello, I am experiencing an issue with the App Intents framework where a parameter of type [String] (String Array) fails to persist user input in the Shortcuts app action editor. Issue Description: When adding an item to the String Array parameter in the Shortcuts app action editor, the input text automatically clears/resets to empty within less than 1 second. This happens spontaneously while the keyboard is still active, or immediately after typing, making it impossible to input any values. Environment: Xcode Version: 26.2 (17C52) iOS Version: 26.2.1 Device: iPhone 17 Code Snippet: import AppIntents import SwiftUI struct TestStringArrayIntent: AppIntent { static var title: LocalizedStringResource = "Test Array Input Bug" static var description: IntentDescription = "Reproduces the issue where String Array input clears automatically." // PROBLEM: // Input for this parameter vanishes automatically < 1s after typing. @Parameter(title: "Test Strings", default: []) var strings: [String] func perform() async throws -> some IntentResult & ReturnsValue<String> { return .result(value: "Count: \(strings.count)") } } Steps to Reproduce: Build and install the app containing the code above. Open the Shortcuts app and create a new shortcut. Add the "Test Array Input Bug" action. Tap the "Test Strings" parameter to add a new item. Type any text (e.g., "Hi"). Observe: Wait for about 1 second Observed Behavior: The text field clears itself automatically. The array remains empty ([]). Expected Behavior: The text should remain in the field and be successfully added to the array. **Filed as Feedback:**FB21808619 Thank you.
0
0
104
Jan ’26
"Show on all spaces" toggles OFF after programmatically setting wallpaper via AppleScript
I'm building an automated wallpaper updater that fetches images from an API and sets them as desktop wallpaper on macOS Tahoe. The automation uses AppleScript combined with database manipulation to ensure wallpaper applies to all spaces. Current implementation (via Apple Shortcuts): wallpaper_path="$1" osascript -e "tell application \"System Events\" to tell every desktop to set picture to POSIX file \"$wallpaper_path\"" sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "UPDATE data SET space=NULL WHERE space IS NOT NULL;" 2>/dev/null killall -HUP Dock Issue First run: Works perfectly - sets wallpaper on all spaces/desktops, "Show on all spaces" is ON After first run: "Show on all spaces" automatically toggles OFF in System Settings Second run onwards: New wallpaper only updates on the active space, inactive spaces show old wallpaper Expected: "Show on all spaces" should remain ON after programmatic wallpaper changes Actual: System Settings automatically disables it, breaking subsequent updates Tested workarounds (all failed): UPDATE data SET space=NULL to clear per-space entries Using every desktop instead of current desktop in AppleScript killall Dock vs killall -HUP Dock vs killall -USR1 Dock Clearing space_id entries from pictures table Running DELETE FROM pictures WHERE space_id IS NOT NULL before setting The database manipulation doesn't prevent macOS from automatically creating per-space entries and disabling the "Show on all spaces" toggle. Question: Is there a way to programmatically set wallpaper while preserving the "Show on all spaces" setting on macOS Tahoe? Environment: macOS: Tahoe (latest) Architecture: Apple Silicon Use case: Daily automated wallpaper updates via Shortcuts
0
0
193
3w
SiriKit: INPlayMediaIntent with a targeted speaker
I've got a streaming Radio app that loads an HLS stream into an AVAudioPlayer. I've set up an Intents extension that notifies SiriKit that my app must handle the INPlayMediaIntent in app, and, I'm able to successfully initiate the stream playing from my phone using the string "Play ". My intent handler in app looks like this: completionHandler(INPlayMediaIntentResponse(code: .success, userActivity: nil)) DispatchQueue.main.async { AudioPlayerService.shared.play() } The Audio Player service, in its init, does the following: try AVAudioSession.sharedInstance().setCategory( .playback, mode: .default, policy: .longFormAudio ) Additionally, in my Info.plist, I have the AirPlay optimization policy set to Long Form Audio. Having said all that, when I try to route my app to play "on a given HomePod speaker" ("play on ") the speaker routing instructions are never followed. I've looked and not been able to find where I might be able to instruct my app to follow the correct path here. I was assuming I could not trigger this behavior manually, as I believe I don't really have any control over AirPlay routing. Is there any guidance for working with SiriKit to do the right thing with regards to audio routing?
0
0
48
1w
App Shortcut parameter title in Spotlight does not update after updateAppShortcutParameters()
We use AppShortcutsProvider with a parameterized App Shortcut. One of the entities has a dynamic display title (e.g. "Everyone is searching: {keyword}") that comes from UserDefaults and is returned in EntityQuery.suggestedEntities() and entities(for:). When we change the keyword and call updateAppShortcutParameters(), the Shortcuts app updates and shows the new title. In Spotlight (Siri Suggestions), the displayed title stays on the old value (e.g. still shows "Everyone is searching: 456" after we switched to "123"). On tap, the shortcut runs with the new value (123), so the execution is correct; only the displayed title in Spotlight is stale. Question: Is this expected? Is there any API or recommended approach to invalidate or refresh the Spotlight suggestion so the displayed title matches the current parameter, or should we avoid dynamic titles for the first suggestion for better UX?
0
0
41
4d