AppleScript

RSS for tag

AppleScript allows users to directly control scriptable Macintosh applications as well as parts of macOS itself.

Posts under AppleScript tag

200 Posts

Post

Replies

Boosts

Views

Activity

Can we please get a coherent automation framework in macOS?
I'm specifically talking about macOS because the others are very different beasts. Since, well literally the first release of OS X 10.0, there has not been a coherent automation framework on the Mac. The last OS to offer that was Mac OS 9.X To define terms, by coherent, I mean from the command line environment up through the user interface. A single, coherent automation framework that is usable across the entire OS, ala PowerShell on windows. That doesn't exist for current macOS, nor has it ever existed for any variant of macOS since again, Mac OS 9.X At best it has been a pastiche of completely different frameworks, operating modalities and languages all desperately trying to work together via osascript and do shell script. That any of it works at all is like a talking dog: the fact the dog talks is a miracle, bad grammar is minor. Yes, I know Shortcuts exist, but shortcuts are a developer managed bit of pseudo-automation. If I limit myself to Shortcuts, then I have little to no ability to do anything beyond what the developer of that application chooses to allow me to do. For example, at least as of Ventura, Dictionary, Font Book, iMovie and others have no shortcuts. I can't create my own shortcut for those apps, the devs have to do that. (the fact that Apple is not flooding us with Shortcuts shows how little Apple cares as a company about this. Individual teams wax good and bad, but clearly, Apple doesn't think dogfooding here is important.) (Note: if your only comment is to ask why anyone would care about automating , that's absolutely not the point. The idea is to make it possible for everyone, not just developers, to create in ways no one can predict outside of an application's constraints.) "Well, there's always AppleScript/JXA" I will not write down the laughter here, but there is laughter. As of Ventura, there are no less than 32 Apple applications with no scripting dictionary at all, so neither AppleScript/JXA can work. You might be able to use UI scripting, but no guarantee there, and UI scripting is a fragile thing, at best suited to a last resort option. Again, Apple could lead the way, they choose not to. But that's only the UI levels. Below the UI, then there's no coherency at all. You're stuck with shell scripts and whatever a given utility's author chose to allow, and sharing data and information is no better than at the UI level, and neither the command line level nor the UI level know the other exists. The only way to combine the two is again: Do Shell Script Osascript That is not a coherent automation framework. Then of course, there's the lack of documentation. AppleScript has inherited at least the language guide, which is well-written and usable, but the command line level has man pages. Which are the most inconsistent things. Some utilities' man pages are remarkably useful, others don't even have man pages. At all. Other utilities man pages have syntax errors for the command that brings up the help page and that is all the man page does. Ponder the disconnect there: --help provides detailed usage information that is not in the man page. The man page says use ---help which is bad syntax. This seems odd, but why is the --help output not also in the man page? Is that not the purpose of the man page? Man page inconsistencies aside, Apple developer support has only ever barely acknowledged automation/scripting and really never supported it except for accidentally. Even in a language like AppleScriptObjecttiveC, (ASOC) which one can use for real apps in the MAS, the response from DTS for help was "use the mailing list." (not that DTS is that good anyway, I had an issue with CoreWLAN in ventura, and have since been ghosted on any notification that the OS bug that was causing me problems has been fixed. Maybe it has, maybe it hasn't. I can test for it, but why did DTS ghost an actual SwiftUI issue for an app written in Swift? ¯_(ツ)_/¯ This is a solveable problem, Microsoft has solved it in terms of language, documentation and coherency, with PowerShell. Leaving aside architectural issues that make it almost impossible to properly secure windows, the way MS treats PowerShell is the example. Windows as an OS has excellent support for automation, the documentation for PowerShell is amazing, (the documentation for a scripting language is better than Apple's entire developer docs, which is just inexcusable.) The difference between automating either platform is night and day, and in a race with two horses, Apple is a distant fifth. The language syntax here is almost a non-issue. In fact, I think using a "powershell'd" version of Swift would be an excellent idea. Create a simpler version of swift in the way PowerShell is a simpler version of C#. Make it so if you need to call a framework outside of the main automation framework, you can do so with ease, ala PowerShell. For example, PowerShell has no GUI primitives the way AppleScript does, so to create a file choose browser in PowerShell, you instead invoke the correct .NET framework: Add-Type -AssemblyName System.Windows.Forms $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ InitialDirectory = [Environment]::GetFolderPath('Desktop') } $null = $FileBrowser.ShowDialog() Ironically, you can do this with ASOC, but only for items that have ObjC interfaces, which will be shrinking. Having a coherent automation framework with a primary language that allows people using it to more easily use "full" Swift and its frameworks as needed is a force-multiplier for Apple. It would help people do more with macOS and maybe other platforms depending on implementation, not less. It would not force people to beg the developers of their apps to write Yet Another Shortcut to do this thing that they can't do, (or have to do the dance to convince the dev that their need is worth the trouble), and it would allow people to solve their problems in their own ways for their own needs. But, it requires Apple to care about this at all, and that is where the problem is. This is fixable, Apple has the resources to fix it, what they lack is interest and desire. But creating and fully supporting a proper automation framework would add so much to macOS and the other platforms by extension that there's no logic behind not doing so. Maybe next year. (in the best lol of all, you can't even create an automation tag for a post. sigh.)
0
5
1.3k
Jun ’23
Sending a new iMessage fails with "Expected class name but found identifier"
Using the highly-rated answer from StackOverflow How to send an imessage text with applescript, only in provided service?: on run {targetBuddyPhone, targetMessage} tell application "Messages" set targetService to 1st service whose service type = iMessage set targetBuddy to buddy targetBuddyPhone of targetService send targetMessage to targetBuddy end tell end run On Ventura, this errors at save with "Expected class name but found identifier." and highlights the first instance of "service". How should the script be corrected? Is there a difference in grammar between releases? This code works on Big Sur.
1
0
1k
Jun ’23
How do I run AppleScript Safely inside my Swift app?
Hey there! I have a Swift app using SwiftUI, and I want to run some AppleScript Safely inside it. Here is my current code: func example() { var script = NSAppleScript(source: """ tell application "Music" play repeat with vlm from 0 to 100 by 1 set the sound volume to vlm delay \(fadetime / 100) end repeat end tell """) DispatchQueue.global(qos: .background).async { let success = script?.compileAndReturnError(nil) assert(success != nil) print(success) } } However, it does not do anything. I have tried using process, however, that simply errors out in -600 "The application is not running." Is there something I am missing here? Thank you!
3
1
2.6k
Jun ’23
Apple script is not doing desired operation for me.
Hey I am new user of MacBook Pro and want to use apple script. I write the script in script editor to delete emails from particular sender. When I click Run this script is running without any error in the Script editor but when I check in the mailbox all mails are still there. Can someone guide me how to use apple scripts. tell application "Mail" set theMessages to every message of inbox whose sender is "xxx" repeat with theMessage in theMessages set theAccount to account of mailbox of theMessage set mailbox of theMessage to mailbox "Trash" of theAccount end repeat end tell
0
0
490
Jun ’23
JXA: Error 6: An error occurred. It works in AppleScript, but not in JXA.
I can't seem to execute Voiceover command with JXA. The following AppleScript works. tell application "VoiceOver" tell commander to perform command "item chooser" end tell However, the following script in JXA throws a mystery error. vo = Application("VoiceOver") vo.commander.performCommand("item chooser") Error 6: An error occurred. I'd really appreciate any help with this! Thanks so much!
0
0
765
Jun ’23
File type and size checking?
I am trying to figure out how to write an AppleScript that will head to a directory, determine if a file with a certain extension exists, and if it does exist, if the file size is greater than a certain size. And run that check every so often. Hung up on how to look at all files in a certain folder, look for that extension and then see if the file size is past my threshold. Ideas? Not too good with AppleScript.
2
0
680
May ’23
performDefaultImplementation of an AppleScript is not called while a menu is open
Apparently, the call to performDefaultImplementation of an AppleScript is called on the main runloop with the defaultModes only, so it is not called while a menu (or contextual menu) is open. This is very unfortunate as it means the execution of these scripts is delayed until after the menu is closed. Looking for a way to change this behaviour but I have no clue how... Thanks ! Daniel
0
0
779
May ’23
[Applescript] set miniatured property failed
Hi, Recently we tested how to minimize app using Applescript as below picture and find some interesting phenomenon. After executing the script, if “miniaturized” marked in green (recognized as parameter), it failed to set minimize property. If “miniaturized” marked in purple, it is ok to set minimize property. Because the syntax is exactly the same, could you help to guide us what is wrong with the script? Sincerely, Thanks, YM
3
0
1.2k
May ’23
Dialog Display in AppleScript
Good morning, I use Automator to create a program and I know how to add an AppleScript script to it. I'm looking to create an AppleScript that displays a dialog box with a question and two options (in the form of two buttons), both of which trigger an app to open, but different, when clicked. I don't use Automator's "Ask for confirmation" block, which indeed displays a dialog box with two options, corresponding to what I'm looking for, but I can't customize the action of the two buttons. Can you help me ? Or give me sample code? Thanks in advance :)
2
0
1.8k
May ’23
Send 'next slide' event to external device via keynote? Maybe via AppleScript?
Send 'next slide' event to external device via keynote? Maybe via AppleScript? We have a video control switch we use for streaming and recording presentations. It is a BlackMagic ATEM switcher. There is a Windows and macOS SDK for control the ATEM switcher, communication is over ethernet from Windows to ATEM device. In our Windows environment, we have a small powershell script that receives a 'next slide' event from Microsoft PowerPoint, that in turn tells the ATEM switcher to change to the camera that is presenting the slide, it holds this input for 30 seconds and then returns to the main speaker camera. This means that as the presenter moves the slide deck forward, automation displays the slide to the remote viewers without any human action. This works well with WIndows, PowerPoint, and ATEM device. We are now trying to create this same behavior with macOS, keynote, and the ATEM SDK for macOS. I am looking for information on how this might be done via AppleScript? Does keynote generate any slide deck specific events that AppleScript can respond to? Or is there some other way to communicate keynote slide changes to some other scripting tool on macOS I can adapt to this goal?
1
0
552
May ’23
Unable to add a slide to presentation using Apple Script
Hi everyone, I am trying to create a presentation and add a slide to it using Apple Script - I have taken help from ChatGPT of course but I keep getting stuck at something or the other and I don't understand what I can do (I am a complete newbie to this so please pardon me!) I have used the below code: tell application "Microsoft PowerPoint" activate set newPresentation to make new presentation set newSlide to make new slide at end of slides of newPresentation end tell But this throws up the error: error "Microsoft PowerPoint got an error: Can’t make or move that element into that container." number -10024 which I mean to understand that I can't tell the application to create a slide? In that case I have tried using 'tell' for the presentation as well with the following code: tell application "Microsoft PowerPoint" activate set newPresentation to make new presentation tell newPresentation set slideCount to count of slides set newSlide to make new slide with properties {position:slideCount + 1} end tell end tell But this throws up the error: error "Microsoft PowerPoint got an error: Can’t make {position:1} into type properties of slide." number -1700 from {position:1} which somehow simply seems to tell me that I can't add the position of the slide into properties? Then I tried the following code: tell application "Microsoft PowerPoint" activate set newPresentation to make new presentation set slideCount to count of slides of newPresentation tell newPresentation set newSlide to make new slide at slide (slideCount + 1) of slides of newPresentation end tell end tell But again I have the following error: error "Microsoft PowerPoint got an error: Can’t get slide 1 of every slide of presentation "Presentation1"." number -1728 from slide 1 of every slide of presentation "Presentation1" which seems to tell me I can't create slide 1 using this method? And now I am confused as to what I can do to create a new slide. Any help is sincerely appreciated!
0
0
707
May ’23
osacompile: no such component "AppleScript"
I created an app that uses AppleScript to automatically convert .numbers files to .csv by opening it in Numbers and using the Export function. After one of the recent updates¹, in Xcode 11.5 (macOS 10.15.5) this no longer works. It shows the error: osacompile: no such component "AppleScript". I get the same error when I manually run the osacompile command in Terminal. ¹The last time I successfully compiled it was on 15 October 2019, so I was already running Catalina, but I don't know which of the updates since then broke it. How to reproduce Even without a valid test.applescript file, this is an easy way to reproduce it: /usr/bin/osacompile -l AppleScript -d -o test.scpt test.applescript This command gives me the same error. A simple way to reproduce it in Xcode is to create a new project and make it an AppleScript App. It can also be reproduced by using this project: https://github.com/hhas/Swift-AppleScriptObjC It's impossible to compile now. Can anyone confirm if this is a bug in macOS / Xcode or just on my system?
7
0
3.3k
Apr ’23
How to call a variable between the strings
Below is the apple script for opening multiple tab need to call the variable ' i ' between the string how this can be done in bash we use $i to call the variable. repeat with i from 1 to 2 tell application "iTerm 2" tell current window create tab with default profile end tell tell current tab of current window set _new_session to last item of sessions end tell tell _new_session select set name to d(i)-tech
0
0
493
Apr ’23
Apple Script - Syntax Error
Hi, New to apple scripting and hoping to get some advice on a Syntax error I'm getting in some code; Expected end of line, etc. but found identifier. set svgFile to export myDoc to file ((path to desktop as string) & "clipboard.svg") as SVG with options ¬ {sVGAutoKerning:false, sVGIncludeFileInfo:false, sVGIncludeUnusedStyles:true, sVGObjectIDPrefix:""} set activePresentation to active presentation set activeSlide to slide selection of slide view of active window of activePresentation The highlighted section in the error is myDoc, presentation and selection Any guidance on what's causing this would be greatly appreciated. Thanks
2
0
1.1k
Apr ’23
Shortcuts – how do users install and how to use URL scheme ?
I would like to distribute a Shortcut with my AppleScript applet (currently the work is done by an Automator Service). I have two questions: Is it possible to automate the installation for users ? It seems that the only way a shortcut can be installed is via the Shortcuts app. So, when they ask for the Shortcut to be installed, the app must be opened and then users have to respond to the install shortcut dialog and, at least, click on "Add Shortcut". Can that process be automated ? A shortcut can be run from a URL, which is very useful. The URL looks like this: shortcuts://run-shortcut?name=[name of shortcut] However, running a shortcut from a URL always opens the Shortcuts app before running the shortcut. This breaks my code which is expecting a web browser to be active. Is there a way of using at the shortcuts URL scheme run the shortcut in place i.e. without opening the shortcuts app ? Or, can the URL scheme be used to call the Shortcuts Event app ? Thanks.
2
0
1.4k
Apr ’23
How does one embed/set a ICC profile/color space into an image using apple script?
How do I get an ICC profile into a form I can embed into an image using Apple Script/Image Events? I'm using the form below make new profile with properties {location:"Macintosh HD/Users/user_N/Desktop/sRGB Profile.icc"}" embed this_image with source profile I've also tried setting the color space property of the image. set the color space of this_image to RGB of course there is more to the code but that is just the part I'm having issues with. I get the error message "Image got an error: can't make profile into type profile" and, error "The variable profile is not defined." number -2753 from "profile" What am I missing here, Anyone know?
3
0
1.3k
Apr ’23
Notarising applet: "Error: No Keychain password item found for profile: <>"
I am trying to submit my AppleScript applet for notarization. My applet is code signed using my developer id. I have stored an app-specific password in my logins keychain with the correct name and account. My developer id is not connected with multiple teams. I tried this on the command line: xcrun notarytool submit "/Users/[home]/Desktop/[applet].zip" --keychain-profile "[name]" --wait The response, very quickly, was: "Error: No Keychain password item found for profile: [name]". Is something else needed to enable notarytool to find the Keychain login item ? Thanks.
3
0
2.4k
Apr ’23
Can we please get a coherent automation framework in macOS?
I'm specifically talking about macOS because the others are very different beasts. Since, well literally the first release of OS X 10.0, there has not been a coherent automation framework on the Mac. The last OS to offer that was Mac OS 9.X To define terms, by coherent, I mean from the command line environment up through the user interface. A single, coherent automation framework that is usable across the entire OS, ala PowerShell on windows. That doesn't exist for current macOS, nor has it ever existed for any variant of macOS since again, Mac OS 9.X At best it has been a pastiche of completely different frameworks, operating modalities and languages all desperately trying to work together via osascript and do shell script. That any of it works at all is like a talking dog: the fact the dog talks is a miracle, bad grammar is minor. Yes, I know Shortcuts exist, but shortcuts are a developer managed bit of pseudo-automation. If I limit myself to Shortcuts, then I have little to no ability to do anything beyond what the developer of that application chooses to allow me to do. For example, at least as of Ventura, Dictionary, Font Book, iMovie and others have no shortcuts. I can't create my own shortcut for those apps, the devs have to do that. (the fact that Apple is not flooding us with Shortcuts shows how little Apple cares as a company about this. Individual teams wax good and bad, but clearly, Apple doesn't think dogfooding here is important.) (Note: if your only comment is to ask why anyone would care about automating , that's absolutely not the point. The idea is to make it possible for everyone, not just developers, to create in ways no one can predict outside of an application's constraints.) "Well, there's always AppleScript/JXA" I will not write down the laughter here, but there is laughter. As of Ventura, there are no less than 32 Apple applications with no scripting dictionary at all, so neither AppleScript/JXA can work. You might be able to use UI scripting, but no guarantee there, and UI scripting is a fragile thing, at best suited to a last resort option. Again, Apple could lead the way, they choose not to. But that's only the UI levels. Below the UI, then there's no coherency at all. You're stuck with shell scripts and whatever a given utility's author chose to allow, and sharing data and information is no better than at the UI level, and neither the command line level nor the UI level know the other exists. The only way to combine the two is again: Do Shell Script Osascript That is not a coherent automation framework. Then of course, there's the lack of documentation. AppleScript has inherited at least the language guide, which is well-written and usable, but the command line level has man pages. Which are the most inconsistent things. Some utilities' man pages are remarkably useful, others don't even have man pages. At all. Other utilities man pages have syntax errors for the command that brings up the help page and that is all the man page does. Ponder the disconnect there: --help provides detailed usage information that is not in the man page. The man page says use ---help which is bad syntax. This seems odd, but why is the --help output not also in the man page? Is that not the purpose of the man page? Man page inconsistencies aside, Apple developer support has only ever barely acknowledged automation/scripting and really never supported it except for accidentally. Even in a language like AppleScriptObjecttiveC, (ASOC) which one can use for real apps in the MAS, the response from DTS for help was "use the mailing list." (not that DTS is that good anyway, I had an issue with CoreWLAN in ventura, and have since been ghosted on any notification that the OS bug that was causing me problems has been fixed. Maybe it has, maybe it hasn't. I can test for it, but why did DTS ghost an actual SwiftUI issue for an app written in Swift? ¯_(ツ)_/¯ This is a solveable problem, Microsoft has solved it in terms of language, documentation and coherency, with PowerShell. Leaving aside architectural issues that make it almost impossible to properly secure windows, the way MS treats PowerShell is the example. Windows as an OS has excellent support for automation, the documentation for PowerShell is amazing, (the documentation for a scripting language is better than Apple's entire developer docs, which is just inexcusable.) The difference between automating either platform is night and day, and in a race with two horses, Apple is a distant fifth. The language syntax here is almost a non-issue. In fact, I think using a "powershell'd" version of Swift would be an excellent idea. Create a simpler version of swift in the way PowerShell is a simpler version of C#. Make it so if you need to call a framework outside of the main automation framework, you can do so with ease, ala PowerShell. For example, PowerShell has no GUI primitives the way AppleScript does, so to create a file choose browser in PowerShell, you instead invoke the correct .NET framework: Add-Type -AssemblyName System.Windows.Forms $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ InitialDirectory = [Environment]::GetFolderPath('Desktop') } $null = $FileBrowser.ShowDialog() Ironically, you can do this with ASOC, but only for items that have ObjC interfaces, which will be shrinking. Having a coherent automation framework with a primary language that allows people using it to more easily use "full" Swift and its frameworks as needed is a force-multiplier for Apple. It would help people do more with macOS and maybe other platforms depending on implementation, not less. It would not force people to beg the developers of their apps to write Yet Another Shortcut to do this thing that they can't do, (or have to do the dance to convince the dev that their need is worth the trouble), and it would allow people to solve their problems in their own ways for their own needs. But, it requires Apple to care about this at all, and that is where the problem is. This is fixable, Apple has the resources to fix it, what they lack is interest and desire. But creating and fully supporting a proper automation framework would add so much to macOS and the other platforms by extension that there's no logic behind not doing so. Maybe next year. (in the best lol of all, you can't even create an automation tag for a post. sigh.)
Replies
0
Boosts
5
Views
1.3k
Activity
Jun ’23
Sending a new iMessage fails with "Expected class name but found identifier"
Using the highly-rated answer from StackOverflow How to send an imessage text with applescript, only in provided service?: on run {targetBuddyPhone, targetMessage} tell application "Messages" set targetService to 1st service whose service type = iMessage set targetBuddy to buddy targetBuddyPhone of targetService send targetMessage to targetBuddy end tell end run On Ventura, this errors at save with "Expected class name but found identifier." and highlights the first instance of "service". How should the script be corrected? Is there a difference in grammar between releases? This code works on Big Sur.
Replies
1
Boosts
0
Views
1k
Activity
Jun ’23
How do I run AppleScript Safely inside my Swift app?
Hey there! I have a Swift app using SwiftUI, and I want to run some AppleScript Safely inside it. Here is my current code: func example() { var script = NSAppleScript(source: """ tell application "Music" play repeat with vlm from 0 to 100 by 1 set the sound volume to vlm delay \(fadetime / 100) end repeat end tell """) DispatchQueue.global(qos: .background).async { let success = script?.compileAndReturnError(nil) assert(success != nil) print(success) } } However, it does not do anything. I have tried using process, however, that simply errors out in -600 "The application is not running." Is there something I am missing here? Thank you!
Replies
3
Boosts
1
Views
2.6k
Activity
Jun ’23
Apple script is not doing desired operation for me.
Hey I am new user of MacBook Pro and want to use apple script. I write the script in script editor to delete emails from particular sender. When I click Run this script is running without any error in the Script editor but when I check in the mailbox all mails are still there. Can someone guide me how to use apple scripts. tell application "Mail" set theMessages to every message of inbox whose sender is "xxx" repeat with theMessage in theMessages set theAccount to account of mailbox of theMessage set mailbox of theMessage to mailbox "Trash" of theAccount end repeat end tell
Replies
0
Boosts
0
Views
490
Activity
Jun ’23
JXA: Error 6: An error occurred. It works in AppleScript, but not in JXA.
I can't seem to execute Voiceover command with JXA. The following AppleScript works. tell application "VoiceOver" tell commander to perform command "item chooser" end tell However, the following script in JXA throws a mystery error. vo = Application("VoiceOver") vo.commander.performCommand("item chooser") Error 6: An error occurred. I'd really appreciate any help with this! Thanks so much!
Replies
0
Boosts
0
Views
765
Activity
Jun ’23
i've noticed many times that applescript doesn't take this syntax
i've tried taking the start date of some event but it throws this error: "expected end of line, but found class name"
Replies
1
Boosts
0
Views
901
Activity
May ’23
File type and size checking?
I am trying to figure out how to write an AppleScript that will head to a directory, determine if a file with a certain extension exists, and if it does exist, if the file size is greater than a certain size. And run that check every so often. Hung up on how to look at all files in a certain folder, look for that extension and then see if the file size is past my threshold. Ideas? Not too good with AppleScript.
Replies
2
Boosts
0
Views
680
Activity
May ’23
Change focus mode to Work with applescript
Is here someone, who could provide me a simple script? My goal is to turn on the Work focus mode with applescript, or with applescript through siri shortcuts. (the main thing is, i need the script code definetly)
Replies
1
Boosts
0
Views
1.6k
Activity
May ’23
performDefaultImplementation of an AppleScript is not called while a menu is open
Apparently, the call to performDefaultImplementation of an AppleScript is called on the main runloop with the defaultModes only, so it is not called while a menu (or contextual menu) is open. This is very unfortunate as it means the execution of these scripts is delayed until after the menu is closed. Looking for a way to change this behaviour but I have no clue how... Thanks ! Daniel
Replies
0
Boosts
0
Views
779
Activity
May ’23
[Applescript] set miniatured property failed
Hi, Recently we tested how to minimize app using Applescript as below picture and find some interesting phenomenon. After executing the script, if “miniaturized” marked in green (recognized as parameter), it failed to set minimize property. If “miniaturized” marked in purple, it is ok to set minimize property. Because the syntax is exactly the same, could you help to guide us what is wrong with the script? Sincerely, Thanks, YM
Replies
3
Boosts
0
Views
1.2k
Activity
May ’23
Dialog Display in AppleScript
Good morning, I use Automator to create a program and I know how to add an AppleScript script to it. I'm looking to create an AppleScript that displays a dialog box with a question and two options (in the form of two buttons), both of which trigger an app to open, but different, when clicked. I don't use Automator's "Ask for confirmation" block, which indeed displays a dialog box with two options, corresponding to what I'm looking for, but I can't customize the action of the two buttons. Can you help me ? Or give me sample code? Thanks in advance :)
Replies
2
Boosts
0
Views
1.8k
Activity
May ’23
Send 'next slide' event to external device via keynote? Maybe via AppleScript?
Send 'next slide' event to external device via keynote? Maybe via AppleScript? We have a video control switch we use for streaming and recording presentations. It is a BlackMagic ATEM switcher. There is a Windows and macOS SDK for control the ATEM switcher, communication is over ethernet from Windows to ATEM device. In our Windows environment, we have a small powershell script that receives a 'next slide' event from Microsoft PowerPoint, that in turn tells the ATEM switcher to change to the camera that is presenting the slide, it holds this input for 30 seconds and then returns to the main speaker camera. This means that as the presenter moves the slide deck forward, automation displays the slide to the remote viewers without any human action. This works well with WIndows, PowerPoint, and ATEM device. We are now trying to create this same behavior with macOS, keynote, and the ATEM SDK for macOS. I am looking for information on how this might be done via AppleScript? Does keynote generate any slide deck specific events that AppleScript can respond to? Or is there some other way to communicate keynote slide changes to some other scripting tool on macOS I can adapt to this goal?
Replies
1
Boosts
0
Views
552
Activity
May ’23
Unable to add a slide to presentation using Apple Script
Hi everyone, I am trying to create a presentation and add a slide to it using Apple Script - I have taken help from ChatGPT of course but I keep getting stuck at something or the other and I don't understand what I can do (I am a complete newbie to this so please pardon me!) I have used the below code: tell application "Microsoft PowerPoint" activate set newPresentation to make new presentation set newSlide to make new slide at end of slides of newPresentation end tell But this throws up the error: error "Microsoft PowerPoint got an error: Can’t make or move that element into that container." number -10024 which I mean to understand that I can't tell the application to create a slide? In that case I have tried using 'tell' for the presentation as well with the following code: tell application "Microsoft PowerPoint" activate set newPresentation to make new presentation tell newPresentation set slideCount to count of slides set newSlide to make new slide with properties {position:slideCount + 1} end tell end tell But this throws up the error: error "Microsoft PowerPoint got an error: Can’t make {position:1} into type properties of slide." number -1700 from {position:1} which somehow simply seems to tell me that I can't add the position of the slide into properties? Then I tried the following code: tell application "Microsoft PowerPoint" activate set newPresentation to make new presentation set slideCount to count of slides of newPresentation tell newPresentation set newSlide to make new slide at slide (slideCount + 1) of slides of newPresentation end tell end tell But again I have the following error: error "Microsoft PowerPoint got an error: Can’t get slide 1 of every slide of presentation "Presentation1"." number -1728 from slide 1 of every slide of presentation "Presentation1" which seems to tell me I can't create slide 1 using this method? And now I am confused as to what I can do to create a new slide. Any help is sincerely appreciated!
Replies
0
Boosts
0
Views
707
Activity
May ’23
osacompile: no such component "AppleScript"
I created an app that uses AppleScript to automatically convert .numbers files to .csv by opening it in Numbers and using the Export function. After one of the recent updates¹, in Xcode 11.5 (macOS 10.15.5) this no longer works. It shows the error: osacompile: no such component "AppleScript". I get the same error when I manually run the osacompile command in Terminal. ¹The last time I successfully compiled it was on 15 October 2019, so I was already running Catalina, but I don't know which of the updates since then broke it. How to reproduce Even without a valid test.applescript file, this is an easy way to reproduce it: /usr/bin/osacompile -l AppleScript -d -o test.scpt test.applescript This command gives me the same error. A simple way to reproduce it in Xcode is to create a new project and make it an AppleScript App. It can also be reproduced by using this project: https://github.com/hhas/Swift-AppleScriptObjC It's impossible to compile now. Can anyone confirm if this is a bug in macOS / Xcode or just on my system?
Replies
7
Boosts
0
Views
3.3k
Activity
Apr ’23
Where Is The AppleScript Project Option In Xcode 14 Beta
I have just installed Xcode 14 Beta but there is no option to make an AppleScript project. Is this no longer available ?
Replies
7
Boosts
0
Views
2.3k
Activity
Apr ’23
How to call a variable between the strings
Below is the apple script for opening multiple tab need to call the variable ' i ' between the string how this can be done in bash we use $i to call the variable. repeat with i from 1 to 2 tell application "iTerm 2" tell current window create tab with default profile end tell tell current tab of current window set _new_session to last item of sessions end tell tell _new_session select set name to d(i)-tech
Replies
0
Boosts
0
Views
493
Activity
Apr ’23
Apple Script - Syntax Error
Hi, New to apple scripting and hoping to get some advice on a Syntax error I'm getting in some code; Expected end of line, etc. but found identifier. set svgFile to export myDoc to file ((path to desktop as string) & "clipboard.svg") as SVG with options ¬ {sVGAutoKerning:false, sVGIncludeFileInfo:false, sVGIncludeUnusedStyles:true, sVGObjectIDPrefix:""} set activePresentation to active presentation set activeSlide to slide selection of slide view of active window of activePresentation The highlighted section in the error is myDoc, presentation and selection Any guidance on what's causing this would be greatly appreciated. Thanks
Replies
2
Boosts
0
Views
1.1k
Activity
Apr ’23
Shortcuts – how do users install and how to use URL scheme ?
I would like to distribute a Shortcut with my AppleScript applet (currently the work is done by an Automator Service). I have two questions: Is it possible to automate the installation for users ? It seems that the only way a shortcut can be installed is via the Shortcuts app. So, when they ask for the Shortcut to be installed, the app must be opened and then users have to respond to the install shortcut dialog and, at least, click on "Add Shortcut". Can that process be automated ? A shortcut can be run from a URL, which is very useful. The URL looks like this: shortcuts://run-shortcut?name=[name of shortcut] However, running a shortcut from a URL always opens the Shortcuts app before running the shortcut. This breaks my code which is expecting a web browser to be active. Is there a way of using at the shortcuts URL scheme run the shortcut in place i.e. without opening the shortcuts app ? Or, can the URL scheme be used to call the Shortcuts Event app ? Thanks.
Replies
2
Boosts
0
Views
1.4k
Activity
Apr ’23
How does one embed/set a ICC profile/color space into an image using apple script?
How do I get an ICC profile into a form I can embed into an image using Apple Script/Image Events? I'm using the form below make new profile with properties {location:"Macintosh HD/Users/user_N/Desktop/sRGB Profile.icc"}" embed this_image with source profile I've also tried setting the color space property of the image. set the color space of this_image to RGB of course there is more to the code but that is just the part I'm having issues with. I get the error message "Image got an error: can't make profile into type profile" and, error "The variable profile is not defined." number -2753 from "profile" What am I missing here, Anyone know?
Replies
3
Boosts
0
Views
1.3k
Activity
Apr ’23
Notarising applet: "Error: No Keychain password item found for profile: <>"
I am trying to submit my AppleScript applet for notarization. My applet is code signed using my developer id. I have stored an app-specific password in my logins keychain with the correct name and account. My developer id is not connected with multiple teams. I tried this on the command line: xcrun notarytool submit "/Users/[home]/Desktop/[applet].zip" --keychain-profile "[name]" --wait The response, very quickly, was: "Error: No Keychain password item found for profile: [name]". Is something else needed to enable notarytool to find the Keychain login item ? Thanks.
Replies
3
Boosts
0
Views
2.4k
Activity
Apr ’23