My AppleScript applet has a user guide in its resources folder. The guide is in PDF format. To show the guide, my applet has this code:
set path_to_Applet_alias to path to me as alias
set help_file to (path to resource "Help.pdf" in bundle path_to_Applet_alias) as string
tell application "Finder"
open file help_file
end tell
That code works. The applet is localised for a few languages. When I set the language in my applet to another language, e.g. French, that code punches an error:
"The application "Preview" can't be opened" -1703
According to Apple, the "-1703" error means "The wrong data type was detected". But, the data type hasn't changed.
I suspect something is going on with the translation but, I can't figure out what.
Any ideas ?
Post
Replies
Boosts
Views
Activity
My AppleScript applet is localized for French, German, Italian and Spanish. The applet displays text in the correct language if the preferred language is changed in the "General" pane of the Language & Region preferences. That is, the applet correctly works in all four languages.
However, the "Apps" pane shows Spanish, German and Italian but, does not show French. For example:
Why would the "Apps" pane not show all languages for which the applet is localized ?
Thanks
late 2015 iMac 27", macOS 12.2.1
I have a workflow which is installed as a Service. It is used to call code in my AppleScript applet. The Service has one action: a "Run AppleScript" action. I update the Service quite often with improvements.
I need a way to know whether my users' copy of the Service is out-of-date. I have developed some ideas:
First is to compare file size of user's copy against the copy being distributed. If they are different, then, the user's copy is out-of-date and needs to be updated. That works except that users need to be able to retain changes to their copy of the Service which should not be over-written my by applet.
Second is to make a custom property in the workflow's info.plist file. That, however, is over-written by Automator when it saves the workflow.
Third is to add a comment to the AppleScript code inside the workflow which can be interrogated by my applet. That does work but, opening and reading the workflow file seems like over-kill and runs the risk of that file being over-written or the XML code being corrupted.
Fourth is to add a plain text file to the contents of the workflow which would contain the version detail. My applet could then interrogate that file to get the version and this know whether the user's copy is out-of-date.
I'm inclined to using the 4th idea. However, all of those ideas are kludges.
Is there an Apple sanctioned method of versioning an Automator service workflow ?
Thanks.
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 ?
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) ?
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 ?
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.
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.
I have an AppleScript applet that is used by a range of people with various versions of macOS. A number of components are installed. One of those is FFmpeg. Some users are experiencing an error during the FFmpeg install process which I can't figure out. Here is the (I know, crude) code:set ffmpeg_site to "https://evermeet.cx/pub/ffmpeg/"
set FFmpeg_page to do shell script "curl " & ffmpeg_site & " | textutil -stdin -stdout -format html -convert txt -encoding UTF-8 "
set ffmpeg_version_start to (offset of "version" in FFmpeg_page) + 8
set ffmpeg_version_end to (offset of "-tessus" in FFmpeg_page) - 1
set ffmpeg_version_new to text ffmpeg_version_start thru ffmpeg_version_end of FFmpeg_page
set downloadsFolder_Path to "Users/[home]/Desktop"
set ffmpeg_download_file to quoted form of (downloadsFolder_Path & "/ffmpeg-" & ffmpeg_version_new & ".zip")
do shell script "curl -L " & ffmpeg_site & "ffmpeg-" & ffmpeg_version_new & ".zip" & " -o " & ffmpeg_download_file
set copy_to_path to "/usr/local/bin/"
try
do shell script "unzip -o " & ffmpeg_download_file & " -d " & copy_to_path with administrator privileges
do shell script "chmod a+x /usr/local/bin/ffmpeg" with administrator privileges
on error number -128
-- Trap case where user cancels admin credentials dialog
main_dialog()
end tryMost users have no problem. But, a few users have reported the following:error: cannot open zipfile [ /Users/[home]/Desktop/ffmpeg- 4.2.2.zip ]Operation not permittedunzip: cannot find or open /Users/[home]/Desktop/ffmpeg- 4.2.2.zip, /Users/[home]/Desktop/ffmpeg-4.2.2.zip.zip or /Users/[home]/Desktop/ffmpeg-4.2.2.zip.ZIP.Those people are all using macOS Catalina. I can't figure out what is causing the error.I have tested the applet on a clean install of Catalina and had no errors.It appears those users do have permission to access /usr/local/bin – the applet installs another component in that folder earlier in the install sequence (in that case the executable is saved into /usr/local/bin using a call to "curl"). Users are also able to manually copy FFmpeg to that folder.The FFmpeg download is completed – users are able to extract the executable from the Zip file and move it to /usr/local/bin using other unarchive tools e.g. Keka – suggesting that the Zip file is not corrupted.Users confirm they have entered their admin credentials correctly.I can't figure out why this is happening to just some users. I believe other users on macOS Catalina have had no trouble. My own testing on a Catalina clean install produced no errors.My only guess at present is that there is a problem for UnZip with the permissions on the downloaded FFmpeg file. But, I have nothing to show tbat is the cause and why it would only affect a few Catalina users.Can anyone help with ideas on the possilbe cause ?Thanks.
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 ?
macOS 10.12 Sierra has a different arrangement for folder aliases which reduces their space usage. It's gone from 1.3MB down to <1KB which is great. This will save me nearly a gigabyte of disk space.However, on a restart folder aliases show a generic document icon instead of the normal folder alias icon. I can fix this issue temporarily in each folder individually by refeshing the folder view (e.g. by changing the sort order). But, the problem returns for all aliases after a restart. It doesn't seem to occur during a log off/on.This affects icons created in 10.12 as well as those created earlier.This looks a lot like a bug.Garry.