hi so im trying to create a simple app that has two pressable buttons that turn a spa mode on and off wishing another app
so far I have the UI figured out the app works the only issue is right now when I press spa on I have setup so it opens Siri Shortcuts and enables the shortcut is there a way to make the app revert back to mine after the action is done? or is there another way to open the other app and navigate to the button within that app and enable it behind my app
Automation & Scripting
RSS for tagLearn about scripting languages and automation frameworks available on the platform to automate repetitive tasks.
Post
Replies
Boosts
Views
Activity
So Recently I’ve been making shortcuts and I noticed that I can prompt chatgpt with shortcuts to add extra functionality, I like this idea but there is 1 flaw with it and that is there is no ability to remove chats automatically, I suppose this would be fine except every time the shortcut is run it creates a new chat, usually I would have made it to remove the chat after the shortcut is finished, but since I can’t the chats would pile up as there is no way of getting rid of them automatically and it would be tedious to manually delete all the chats.
also sorry if I chose the wrong topic and subtopic, I couldn’t find a topic about shortcuts
Hi everyone,
I'm trying to use Automator to batch process PDF files. I have hundreds of academic journal article PDFs whose page sizes vary from 5x7 inches to A4 format (8.27 x 11.69 inches). I want to scale all the PDFs to US Letter size (8.5 x 11.0 inches) such that smaller originals remain 100% scale but are centered on the larger page and larger originals are scaled down to fit the page.
Manually opening a PDF in Preview.app, scaling it to US Letter paper, and using the Save as PDF option is producing the desired output for me. I captured my workflow using the Watch Me Do action in Automator, then adjusted it into the following AppleScript.
-- a Get Specified Finder Items action to specify the input PDFs precedes this script
on run {input, parameters}
repeat with filePath in input
-- Open the file in Preview
tell application "Preview"
open filePath
activate
end tell
-- Give Preview some time to open the file
delay 2.0
-- Press ⌘P
set timeoutSeconds to 0.25
set uiScript to "keystroke \"p\" using command down"
my doWithTimeout(uiScript, timeoutSeconds)
-- Click the “Scale to Fit:” radio button.
delay 2.0
set timeoutSeconds to 2.0
set uiScript to "click radio button \"Scale to Fit:\" of radio group 1 of group 1 of group 2 of scroll area 2 of splitter group 1 of sheet 1 of window 1 of application process \"Preview\""
my doWithTimeout(uiScript, timeoutSeconds)
-- Click the “<fill in title>” menu button.
delay 4.0
set timeoutSeconds to 2.000000
set uiScript to "click menu button 1 of group 2 of splitter group 1 of sheet 1 of window 1 of application process \"Preview\""
my doWithTimeout( uiScript, timeoutSeconds )
-- Save as PDF…
delay 2.0
set timeoutSeconds to 2.0
set uiScript to "click menu item 2 of menu 1 of splitter group 1 of sheet 1 of window 1 of application process \"Preview\""
my doWithTimeout(uiScript, timeoutSeconds)
-- Click the “Save” button.
delay 8.0
set timeoutSeconds to 2.0
set uiScript to "click UI Element \"Save\" of sheet 1 of sheet 1 of window 1 of application process \"Preview\""
my doWithTimeout(uiScript, timeoutSeconds)
-- Press ⌘W to close the file
delay 0.25
set timeoutSeconds to 2.0
set uiScript to "keystroke \"w\" using command down"
my doWithTimeout(uiScript, timeoutSeconds)
end repeat
return input
end run
on doWithTimeout(uiScript, timeoutSeconds)
set endDate to (current date) + timeoutSeconds
repeat
try
run script "tell application \"System Events\"
" & uiScript & "
end tell"
exit repeat
on error errorMessage
if ((current date) > endDate) then
error "Can not " & uiScript
end if
end try
end repeat
end doWithTimeout
My problem arises at the Save as PDF step. When this action runs, I see the PDF menu pop open:
but the Save as PDF... menu item doesn't get clicked. Instead, I get an error:
Can anyone advise on how to overcome this error?
Instead of a .sdef file (or older formats) made in advance and stored in an app’s bundle, I wonder if the script dictionary can be set soon after the app opens? I seen related API, with a note that the scripting file reader ultimately calls that API. I grok about 90% of that API, but I’m not sure it’s possible.
We are trying to open an application "xyz.app" It worked fine until 15.1.1 versions. But facing issues with 15.2 and 15.3
The application is working fine when we navigate to xyz.app/Contents/MacOS/ and run applet in this directory. But the error "Not authorized to send Apple events to Terminal" occurs when we are trying to open the app directly.
We have tried with all the available solutions like giving full disk access to terminal and application, adding my application to automation in privacy and security tabs in settings.
Any help would be appreciated.
Thanks!
Hi folks,
I've got some music that I want playing on iTunes all the time on an older system, but it'll sometimes stop. I tried making a Applescript to check and play the music/playlist again if it stops, but I keep getting a timeout error.
This is the AppleScript:
repeat
tell application "iTunes"
if player state is paused then
tell application "iTunes" to play
end if
delay 30
end tell
end repeat
I get this error:
AppleEvent timed out.
iTunes got an error: AppleEvent timed out. (-1712)
I can't figure out why I'm getting a timeout error... anyone have any ideas?
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
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?
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 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?
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.
We created a script .scpt that is run before an operation. the script use a login via Safari. almost always it works but sometimes not. if we log on the machine the script will work. do you have idea of the problems? Thanks
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.
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:
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?
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
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!
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 ?
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 am unable to get a result from a simple AppleScript calculator set of commands.
The calculator shows the right result, but I cannot capture the result to place in the clipboard and read it.
I also ran this in the script editor.
Python File