Tuesday, September 21, 2021

#1 2021-08-24 01:42:04 pm

Rikyli
Member
Registered: 2021-02-15
Posts: 10

AppleScript app Assistive access trouble

I have saved an apple script as an app and when I launch it I get the following error

System Events got an error: DualFinder is not allowed assistive access. (-1719)

I have given the app accessability permission in system settings but still recieve this error any ideas

It runs fine from the script editor but the final project needs to be a stay open app

Applescript:


tell application "System Events"
   tell application "Mission Control" to launch
   tell group 2 of group 1 of group 1 of process "Dock"
       click (every button whose value of attribute "AXDescription" is "add desktop")
       tell list 1
           set countSpaces to count of buttons
           delay 0.5
           click button (countSpaces)
       end tell
   end tell
end tell

Offline

 

#2 2021-09-10 12:47:03 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 2038

Re: AppleScript app Assistive access trouble

DualFinder is the name of your script application as I understand. So,
1) First, clean your script:

Applescript:


tell application "Mission Control" to launch

tell application "System Events" to tell group 2 of group 1 of group 1 of process "Dock"
   click (every button whose value of attribute "AXDescription" is "add desktop")
   delay 0.5
   click last button of list 1
end tell

2) Save it as usual application (not stay-open)
3) Launch it, give to it permission to control your computer. Go System Preferences-->Security&Privacy----> Accessibility. See: if the checkbox is checked (and application throws error) , then uncheck it and check again. If it is unchecked then simply check it.
4)  If this doesn't help, then remove DualFinder.app from the list using MINUS button, then  go step 3) again .


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#3 2021-09-10 01:40:09 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 5426

Re: AppleScript app Assistive access trouble

Riklyi wrote:

I have given the app accessability permission in system settings but still recieve this error any ideas


The probable reason for this is the 'countSpaces' variable, which, being a run handler variable (ie. used in the top level of the script), is saved back to the script file every time the script's run. This changes the file's modification date and the security system thinks it's a new file.

KniazidisR's suggestion gets rid of the variable.


NG

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)