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

AppleScript help
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
0
0
369
Feb ’25
App Automatically Deleted from Applications Folder - OSX
I made an application in Script Editor and it works as expected. But the app seems to be getting automatically deleted at random times. For example, I made it a few days ago, tested it successfully, then went back today to look for it and it was gone. Tested this multiple times. I bit more detail about my process: I wrote the app in Script editor, exported it as an Application with run-only checked and no code signing after manipulating a few things (.plist file, .icns file), I then remove extended attributes and code-sign using terminal. I have an Apple developer account that I use to code-sign: xattr -cr <path_to_app> codesign -s <my_developer_account> <path_to_app_bundle> then I copy the app into my Applications folder and test it successfully a day or more later, the app is gone (and I haven't even opened it again) Ventura 13.1, Mac Book Pro 2021
3
1
1.1k
Feb ’25
Changing pad colour in Image Events
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?
0
0
319
Feb ’25
Dynamically creating and modifying shortcuts
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?
0
0
358
Jan ’25
Automation for message received
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?
0
0
276
Jan ’25
AppleScript nd adobe indesign
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.
0
0
353
Jan ’25
Help with app automation permissions
Hi, I am trying to make an app that uses Spotify's web API to play songs. For the web API to work, Spotify needs to be running, and my Mac has to be recognized as an active device. For my Mac to be recognized as an active device, I have to play a song for a very short amount of time (under a second). I want to make my app automatically do that on launch. I already wrote the AppleScript in Automator, and it worked. It successfully launched Spotify, played a song for 0.5 seconds, then hid itself. After writing the code, I tried to implement it into my app to run on startup, but I ran into a problem. The app only started the Spotify app on my mac, and gave me an error that told me it wasn't running. What do I do? Is this an issue with the permissions of the app, or something else? I have given the app the "Apple Events" entitlement. This is the error I am getting. Note that the app opens Spotify, after which it gives me this. Error: { NSAppleScriptErrorAppName = Spotify; NSAppleScriptErrorBriefMessage = "Application isn\U2019t running."; NSAppleScriptErrorMessage = "Spotify got an error: Application isn\U2019t running."; NSAppleScriptErrorNumber = "-600"; NSAppleScriptErrorRange = "NSRange: {31, 8}"; } This is the function I am trying to use to do the actions with Spotify: func runAppleScript() { let appleScript = """ tell application "Spotify" activate if player state is not playing then play track "spotify:track:5XSKC4d0y0DfcGbvDOiL93" delay 1 pause end if end tell tell application "System Events" tell process "Spotify" set frontmost to true delay 1 keystroke "h" using {command down} end tell end tell """ var error: NSDictionary? if let scriptObject = NSAppleScript(source: appleScript) { scriptObject.executeAndReturnError(&error) } if let error = error { print("Error: \(error)") } } Any help is appreciated. Thank you in advance.
1
0
404
Jan ’25
Apple Mail and Drag&Drop
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?
0
0
380
Dec ’24
ShortCuts: Send email with email address as a parameter
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
0
0
432
Dec ’24
Batching CatalogSearchRequests for Spotify Playlist conversion
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!
0
0
430
Dec ’24
Not authorized to send Apple events to Microsoft Excel
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 ?
1
0
570
Dec ’24
Intents not showing up in Shortcuts app
I have an existing iOS app with shortcuts support, and I am trying to bring the same shortcuts to my Mac app in macOS Monterey. In my case, I have added the same intents definition file to my Mac target app, added "Intents eligible for in-app handling" to my Info.plust file and added the intent names, and made sure all the intent handling code is part of both iOS and Mac targets. Still, when I build and run the app on macOS Monterey, the new shortcuts don't show in the shortcut editor at all. I've tried closing and restarting the Shortcuts app, but no luck. The build logs do show the intents being built, but they're just not showing up in the Shortcuts app. I tried 'donating' one of the intents in my Mac app code, but got an error: Cannot donate interaction with intent that has no valid shortcut types Not sure what to try to make it work. Thanks.
4
0
2.2k
Dec ’24
quit apps, launch apps from Calendar
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"
0
0
482
Nov ’24
Writing an app to help install DMGs/PKGs
Hi all I work in music production, the way the tools are set up is we use many tools (plugins) inside one larger app (a DAW), as such the process of setting up a machine to do work involves running 50-100+ different installers to get all tools installed. I'd like to write a small app that will automate the install process. I have a working approach for this where all steps work when run individually in terminal or via AppleScript, but as I create one unifying app I am running into an issue where any app I create in Xcode is not allowed to mount DMGs or give commands to terminal (even if I make a build app package and move it out of the Xcode directory, and even if I give explicit permission via settings) and if I try to have the app try to do the works via terminal it also can't seem to access terminal. I think there are some limitations I'm missing here. Any tips?
2
0
558
Nov ’24
macOS how to download previous versions
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!
2
0
542
Nov ’24
Remotely Quit Remote Desktop
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}'
0
0
573
Oct ’24