Post

Replies

Boosts

Views

Activity

Can a macOS service be called from a web browser bookmark ?
I have a macOS service which works well. It is invoked from the "General" section of the "Service" menu in web browsers and requires no input. The workflow contains AppleScript which does what I need. To make the Service more accessible I would like to call it using a web browser bookmark. That would require a custom URL scheme. However, as far as I can find, custom URL schemes can only call apps, not services. Is that correct ? Are custom URL schemes only able to start apps or can they call a service ? If a custom scheme can call a Service, how ? Thanks.
0
0
659
Feb ’21
How to create a Python3 runtime
My AppleScript applet provides a GUI for a Python script. A new version of the Python script requires Python3. That means I need to include a Python3 runtime with my applet (or provide a way for users to install). I know almost nothing about Python. How can I create a Python3 runtime for users ? What is in a Python runtime for users ? Must the runtime be in my applet's bundle or must it be installed somewhere ? Must the runtime include all the developer tools that come with Python (e.g. IDLE) ?
0
0
730
Sep ’21
AppleScript tell Finder to open file => Permission error
I have a plain text file saved to my Desktop the result of an earlier script. I have a simple AppleScript telling Finder to open the text file: set open_this to (path to desktop as text) & "Test.txt" tell application "Finder" to open alias open_this This results in the error: "The document "Test.txt" could not be opened. You don't have permission. To view or change permissions, select the item in the Finder and choose File > Get Info." Weirdly, if I duplicate the text file and tell Finder to open it I get: "Finder got an error: Handler can’t handle objects of this class." I've check permissions on the file and they look normal – my user account has read & write permission. I have given "Full Disk Access" to Script Debugger, my AppleScript IDE. This was a known bug in macOS 12.3/12.3.1 and I thought it has been fixed in 12.4 when I tested the beta. But, it is definitely a bug in macOS 12.4. Does anyone have a way in AppleScript of telling Finder to open a file ?
0
0
1.7k
Jul ’22
AppleScript – "text item delimiters" uses non-specified delimiters - FIXED
SOLVED I want to parse some plain text and pull out the 11th and 13th words. I can't get it to work because "text item delimiters" sometimes treats additional characters as delimiters. set test_text to "one two three four five six seven eight nine ten elev-en twelve thir-teen" set AppleScript's text item delimiters to "" set AppleScript's text item delimiters to {" "} set word_11 to word 11 of test_text set word_12 to word 12 of test_text set word_13 to word 13 of test_text set word_14 to word 14 of test_text set word_15 to word 15 of test_text set AppleScript's text item delimiters to "" log word_11 & " " & word_12 & " " & word_13 & " " & word_14 & " " & word_15 The result is: (elev en twelve thir teen) But the result should be an error – it should NOT be using the hyphen as a delimiter. Why is the hyphen being used as a delimiter ? UPDATE: Because I should be using "text item" instead of "word"
0
0
973
Mar ’23
Can't get "shortcuts sign" to work
According to the Shortcuts User Guide, the following command should sign a shortcut: shortcuts sign --mode anyone --input "Share me.shortcut" --output "Share me signed.shortcut" I have tried that formulation but get this error: Error: The file couldn’t be opened because it isn’t in the correct format. So, I tried to sign an exported shortcut: shortcuts sign --mode anyone --input /Users/[Home]/Test.shortcut --output /Users/[Home]/Test-signed.shortcut That returns nothing suggesting there was no error. But codesign says: /Users/[Home]/Test-signed.shortcut: code object is not signed at all Is code signing working for shortcuts ? Is there a way to sign a shortcut ?
0
0
750
Apr ’23
Can volunteer groups apply for a developer ID ?
There is a volunteer run group on GitHub who maintain a well known public domain cross-platform Python script. They build binaries for Linux, Windows and macOS. The macOS binaries are only ad-hoc signed. Thus, in macOS 15, they are rejected by Gatekeeper – requiring user intervention to be used. There are a lot of components each of which must be approved in "Settings" with admin credentials. It would be best if these binaries were code signed. However, the core group of devs changes over time and so, using one person's name might not be ideal. Can such a volunteer group apply for a developer certificate so that they can sign the macOS binaries ? I ask because Apple's requirements for enrolling in the Development Program include that an organisation be a legal entity and this group is not a legal entity. Thnaks.
0
0
555
Oct ’24
SwiftUI Tutorial – Can't understand what instructions mean
I have been trying hard to work through the first SwiftUI tutorial. It's supposed to take only 40 mins. But, I have been trying all day and got only to Section 4, Step 3. I have found nearly every step to be hard because the language is new and there are no definitions or glossary to help understand what things mean. For example, I had to Google "lifecycle" and read a great simple explanation on another site before I understood what it means. Anyway, in Step 3 it says: "Replace the text view with the image of Turtle Rock by using the Image(_:) initializer, passing it the name of the image to display." Now, how do I replace the text view with the Image(:)initializer – what IS an Image(:) initializer ? [And why does some of the text I've just typed show in italics ?] Where is it ? – I'm staring at XCode and not seeing it. I tried typing over this: Text("Hello, World!") and replaced that with Image(_:). But the result was an impenetrable error: "Cannot find 'Image' in scope" ! So, what does scope mean in this context ? And, next, how do I "pass" anything to it ? The image ? The word "Image" ? Something else ? What does "pass" mean ? Do I type the name of the image file somewhere, if so, where ? The next Step scares the willies out of me: "Add a call to clipShape(Circle()) to apply the circular clipping shape to the image." What is a call and where do I find a "clipShape" ? OK I just typed in "clipShape(Circle())" and seemed to do something but now I get this error: Instance method 'clipShape(_:style:)' requires that 'some View' conform to 'Shape'". Then Step 5 says: "Create another circle with a gray stroke, and then add it as an overlay to give the image a border." So, where is this "gray stroke" thing ? And how do I add it as an overlay ? Do I click and drag something into somewhere ? I'm not a total dill. I've been running an AppleScript applet on GitHub for 4 years and it works. I've used something like 20 scripting and similar languages over the decades. I first used an Apple Mac in 1986. SwiftUI looks like a good option for re-developing the applet. But, at this rate it'll take another 4 years. Can anyone talk me down to a safe landing ?
1
0
918
Sep ’21
AppleScript Scripting Additions' dialogs - why does cancel cause an error ?
AppleScript's Scripting Additions dictionary contains a number of useful dialogs (e.g. "display dialog", "choose file", "choose from list"). As with most dialogs, the user can cancel and go on with something else. But, when the user presses the "Cancel" button or presses the "esc" key, the dialog returns an error -128. Why is it so ? This can be controlled with some dialogs by defining the buttons to be e.g. "No" and "Yes". The AppleScript code can then respond appropriately to the "No". That avoids the issue but at least, then, there is no need to put the "display dialog" into a try block. But, the buttons on some dialogs cannot be customised e.g. "choose file name". So, every time those dialogs are used, they must be wrapped in a try block so that the script can deal with the user's cancelling of the dialog. Instead, why not return a "Cancel" or a boolean "false" ? If the user presses the "Cancel" button why not return something to indicate that instead of banging an error that has to be trapped ? For example for display dialog it could be {button returned:"Cancel", gave up:false} and for choose file it would be [missing]. I guess that changing this after so many years of people crafting scripts around it would be risky. But, why do those dialogs have to return an error ?
1
0
992
Feb ’22
AppIcon not showing in "About" box or app switcher
I can't get my app's logo to show in the "About" box nor in the app switcher. I have: created "Assets.xcassets" created "AppIcon" added 10 image files of the logo to the AppIcon image well [? right terminology ?] saved and built the project – there are no errors or warnings When I run the project, I still get the default image showing in the About box and in the app switcher. Because first attempt failed, I changed "applet" to "AppIcon" in "App Icons and Launch Screen" in "General" settings. That did not change the result. I also toggled "Include all app icon assets" which also did not change the result. Weirdly, my app's logo DOES show beside the app name in every item of "Build Settings". Do I need to do something else to change the default image in the "About" box ? Thanks. [Xcode 16.2 on macOS 15.3.2.]
1
0
253
Mar ’25
Restrict automator service to just web browsers
I have an Automator Service which uses AppleScript to copy the URL in the front tab of a web browser. Its works without requiring the user to select the URL in the address bar. Thus, it has no input. I don't want to change that behaviour.Currently the service appears in the Service Menu of all applications. I want the Service to only appear in the Service Menu of web browsers (ie. Safari, Chrome, Firefox etc).I suppose I could create a separate Service for each web browser but, that seems ridiculous.Does anyone know of a way to achieve this ?
3
0
1.3k
Feb ’21
Seeking documentation – AppleScript applets containing Open/Save dialogs auto-create preferences
I've just found that AppleScript applets which generate Open or Save dialogs (e.g. via NSPathControl's NSPathStylePopUp) automatically create a preference file in the user's home preferences folder. The file has the same name as the applet's ID (e.g. com.apple.script.id.myapplet.plist). The file might contain value-key pairs for NSNavLastRootDirectory, NSNavPanelExpandedSizeForOpenMode, NSWindow Frame NSNavPanelAutosaveName etc. I have Googled and search but have not been able to find documentation on this. Is there any documentation which explains this behaviour and provides advice on how to use it ? Thanks.
2
0
746
Sep ’21
NSBox – What is difference between BoxType.separator and BoxType.primary
Documentation says: BoxType.primary Specifies the primary box appearance. BoxType.separator Specifies that the box is a separator. Nice, but what does it mean ? What does a "primary" box look like ? How is it different to a "secondary" box ? I have tried both forms (in ASOC) and they look the same. So, is there a difference in how they look ? Thanks.
2
0
818
Mar ’23