applescript can't delete any mailbox - applescript

how to delete a mailbox?
tell application "Mail"
delete mailbox "complaints" of account "ACME LLC"
end tell
gives me error "AppleEvent handler failed." number -10000"
MacOs Sierra 10.12
It is not a problem of file permission because renaming mailboxes works fine

Related

In Mojave Filemaker access by applescript throws privilege Error

I have an applescript which reads a cell from filemaker. Since Mojave (OS 10.14) it fails with
error "FileMaker Pro 18 Advanced got an error: A privilege violation occurred." number -10004
I assume it has to do with the security features of Mojave. How can I fix this?
tell application "FileMaker Pro 18 Advanced"
tell document "test.fmp12"
tell table "customerTable"
set customerName to data of cell "nameOfCustomer"
end tell
end tell
end tell
the set command throws the error.
In System Preferences/Security & Privacy/Privacy
I gave full disc access to Script Editor and Filemaker Pro Advanced
did you go to File menu/Manage/Security and edit the Privilege Set to Allow Apple Events for the FMP file?

Simple AppleScript to enable one macOS Mail account, disable another?

I have used a simple AppleScript that toggles between active and inactive macOS Mail accounts that has worked peachy up until macOS 10.15 Catalina. I generally trigger this through the Script Menu to hide one account and enable another, but have also tried by simply opening and running it. Either way, it's now failing with the error:
Blockquote error "Mail got an error: AppleEvent handler failed." number -10000
Here's the script: what am I missing here to having this work in Catalina?
tell application "Mail"
set enabled of account "Mac" to false
set enabled of account "Windows" to true
end tell

applescript and application process name on OSX 10.10

I have an application that I'm running on OSX, and I have this AppleScript that was working on 10.9, but it seems that it does not work on 10.10
try
tell application \"System Events\" to set processPath to application file of application process "My Application"
return POSIX path of processPath
on error errMsg
return ""
end try
When I run this in the AppleScript editor, it gives me the error that "System events got an error: Can't get application process "My Application".
I checked the Activity Monitor, and indeed, there is no process called "My Application" in there. The associated process with my application is now registered by the name "SWT". I confirmed this by killing the "SWT" process, and it killed my app.
My question is, what has changed from 10.9 to 10.10, and why is my application registered as SWT process, instead of "My Application", as it was in 10.9? Additionally, what changes do I need to make in order to register the process by the name of "My Application" (something which I presume will work)?
Update: I tried setting the Application name to "My Application", which worked, and now I am able to see a process called "My Application" in the Activity Monitor, but the AppleScript is still not working. The error that I'm getting now is:
Can’t make alias \"Macintosh HD:Library:Java:JavaVirtualMachines:jdk1.7.0_71.jdk:Contents:Home:bin:java\" of application \"System Events\" into the expected type
Any thoughts on this?
I might have misunderstood your question but if you just want to change your app name from SWT to your application name try this
Display.setAppName("My app name");
This should be set before any display class is initialized.

'tell application "Finder" to restart' brings up WorkflowServiceRunner.xpc wants to make changes

I wrote reboot scripts for both Snow Leopard and Lion to quickly boot between them.
SL script works fine, but it seems Lion has some additional security feature that requires a password when script is run.
I get a dialog requesting my password that says:
"WorkflowServiceRunner.xpc wants to make changes. Type your password to allow this"
Is there a way in code to send pw info so this runs automatically?
You mean you had to type your password because of tell application "Finder" to restart?
In that case, you can use
do shell script "killall Finder"
tell application "Finder" to open

AppleScript - System Events Error : Access for assistive devices is disabled

I have a problem with AppleScript and System Events.
I have check "Enable access for assistive devices" in the “Universal Access” preference pane in System Preferences.
When I try :
arch -i386 osascript -e 'tell application "System Events" to get the position of every window of every process'
I have this error :
System Events got an error: Access for assistive devices is disabled. (-25211)
Do you have any idea ?
Thanks a lot
On Mac OS X 10.9 you actually get the same error when the AppleScript Editor is not allowed to use Accessibility.
Here's how you enable it:
Go to System Preferences > Security & Privacy > Privacy > Accessibility.
Then, just check the checkbox left to the AppleScript Editor and the error should be gone.
The problem is not the assistive devices. AppleScript seems to incorrectly return that error code when it tries to access windows of a process that can never have any windows (in my case it was "Google Chrome Helper").
You need to catch the errors. This works for me:
tell application "System Events"
set procs to processes
set windowPositions to {}
repeat with proc in procs
try
if exists (window 1 of proc) then
repeat with w in windows of proc
copy w's position to the end of windowPositions
end repeat
end if
end try -- ignore errors
end repeat
end tell
return windowPositions
returning a list of coordinate pairs, such as {{1067, 22}, {31, 466}, {27, 56}, {63, 22}, {987, 22}} – is that what you were trying to get?
Similar to the post on this page about Mac OS X 10.9 (Mavericks), to resolve this issue on Mac OS X 10.8 (and likely on earlier versions of OS X also), you need to ensure that the "Enable access for assistive devices" option has been enabled in the Accessibility pane of System Preferences.

Resources