j.smith
j.smith

Reputation: 37

AppleScript, Receiving System Error - System Events got an error: Cant get group 1 of window 1 of process "Mail". Invalid Index

Part of an AppleScript I'm using forwards an email and then places the cursor at the top of the body of the new message. The script works perfectly on my Mac running MacOS Sonoma 14.6.1. It also works on another user's computer running MacOS Ventura 13.6.6. However, the script returns the following error when ran on another user's machine running Ventura 13.6.9:

System Error - System Events got an error: Cant get group 1 of window 1 of process "Mail". Invalid Index

The portion of the code that is failing appears to be at the "tell first window" portion of the below code block:

tell application "System Events"
    tell process "Mail"
        set frontmost to true
        click menu item "Forward" of menu "Message" of menu bar 1
        delay 1
        tell application "Mail" to set bounds of front window to {0, 0, 1000, 1000}
        delay 1
        
        tell first window
            tell group 1 to tell group 1 to tell scroll area 1 to tell UI element 1 to set focused to true
        end tell

    end tell
end tell

Since this works on multiple machines, including one running Ventura, it feels like there is a system setting or permission that needs to be granted on the machine where the code is failing. Unfortunately, I'm not sure what setting/permission this would be. Any help in getting this code, or different code that accomplishes the same goal, to work on the machine running MacOS Ventura 13.6.9 is greatly appreciated.

Thank you.

Upvotes: 0

Views: 70

Answers (0)

Related Questions