System Events got an error

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

System Events got an error Tue Aug 02, 2022 12:21 am • by AK202208
When I run an embedded Applescript I get the following error:
2022-08-02 23:12:02.856 hazelworker[57163] Invoice-36323-R (for testing Hazel).pdf: Rule Receipt expenses matched.
2022-08-02 23:12:02.881 hazelworker[57163] [Error] AppleScript failed: Error executing AppleScript on file /Users/ak/Downloads/Invoice-36323-R (for testing Hazel).pdf.
2022-08-02 23:12:02.881 hazelworker[57163] OSAScript error: {
NSLocalizedDescription = "No user interaction allowed.";
NSLocalizedFailureReason = "No user interaction allowed.";
OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: [0x0,2 \"hazelworker\"]>";
OSAScriptErrorAppNameKey = Hazel;
OSAScriptErrorBriefMessageKey = "No user interaction allowed.";
OSAScriptErrorMessageKey = "No user interaction allowed.";
OSAScriptErrorNumberKey = "-1713";
OSAScriptErrorRangeKey = "NSRange: {0, 0}";
}
2022-08-02 23:12:02.884 hazelworker[57163] Done processing folder Downloads

The applescript is:
set theAttachment to (POSIX path of theFile)
set theSubject to "LayerStack invoice to Expensify"
set theContent to "This is an automated email using Hazel."
set theAddress to "a@aol.com"

display dialog "theAttachment"

tell application "Mail"

activate

set newMessage to make new outgoing message with properties {subject:theSubject, content:theContent & return & return}

tell newMessage
set visible to false
set sender to "a@mac.com"
make new to recipient at end of to recipients with properties {address:theAddress}
make new attachment with properties {file name:theAttachment} at after the last paragraph
send -- use save to draft or send to send
end tell

end tell


Any help appreciated to understand where to look and how to resolve.
Last edited by AK202208 on Tue Aug 02, 2022 11:15 am, edited 1 time in total.
AK202208
 
Posts: 3
Joined: Tue Aug 02, 2022 12:03 am

Re: System Events got an error Tue Aug 02, 2022 9:43 am • by Mr_Noodle
Can you post the script?
Mr_Noodle
Site Admin
 
Posts: 11196
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: System Events got an error Tue Aug 02, 2022 11:17 am • by AK202208
Mr_Noodle wrote:Can you post the script?


Sorry I realised I made a silly mistake when trying to debug, so I reposted with what I was originally trying to do and the error with this original.
AK202208
 
Posts: 3
Joined: Tue Aug 02, 2022 12:03 am

Re: System Events got an error Wed Aug 03, 2022 8:49 am • by Mr_Noodle
I think you need to do a 'tell application "System Events"' around the display dialog line as you need a process that can go GUI stuff to do that for you.
Mr_Noodle
Site Admin
 
Posts: 11196
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: System Events got an error Thu Aug 04, 2022 2:19 am • by AK202208
Mr_Noodle wrote:I think you need to do a 'tell application "System Events"' around the display dialog line as you need a process that can go GUI stuff to do that for you.


I didn't think that was the problem. Anyway, I did as suggested, but I still have the same problem. I think it has to with AppleScript and how it orchestrates with Mac OS.
AK202208
 
Posts: 3
Joined: Tue Aug 02, 2022 12:03 am

Re: System Events got an error Thu Aug 04, 2022 9:30 am • by Mr_Noodle
Have you tried the script outside of Hazel?
Mr_Noodle
Site Admin
 
Posts: 11196
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support