MrSimonC / Toggle-Mac-Function-Keys

This AppleScript allows you to automate the toggling of using Function Keys vs Media Keys on MacOS
MIT License
86 stars 15 forks source link

Toggle Function Keys is not allowed assistive access #16

Closed felipekunzler closed 7 months ago

felipekunzler commented 10 months ago

Getting the following error even after adding the app to the accessibility list under Privacy & Security and restarting the laptop. Script runs fine using Script Editor. Wondering if that's just me.

image

image

cartesian-plane commented 9 months ago

I have this issue too. I don't think this is related to the script itself, as I've seen similar stuff when looking into how to fix it. In the end, I assumed it was just a macOS bug and gave up, though.

MrSimonC commented 9 months ago

Thanks for raising the issue. Quickest update is that I can confirm the problem you're having. 🤔 You are right, it's not you it's macOS. I've even done a reboot and it makes no difference… (reference for historical reasons: macOS. Sonoma, 14.3 (23D56)). I have had this issue before, so let me have a play around and work on it…

MrSimonC commented 9 months ago

Solved! There is a bug in the way that macOS and Script Editor work together.

Rather than using the File > Save (or Save As) menu, instead we need to use the File > Export menu and tick and select CodeSign: SignToRunLocally. See the image below:

This won't work:

Screenshot 2024-02-07 at 23 46 28

Instead, we must do this:

Screenshot 2024-02-07 at 23 47 45

which presents the usual first permission request:

Screenshot 2024-02-07 at 23 48 09

Put upon running the application, we now get this necessary second request:

Screenshot 2024-02-07 at 23 49 09

This second request places a new entry in the Privacy & Security > Automation menu and then allows system events to be selected in the automation menu, which makes all the difference.

… It's late in my time zone right now, but I'll update the documentation on the main page soon about this.

magnanimous123 commented 9 months ago

this isn't working for me :( I can't get the second request to pop up - any idea how to fix this?

MrSimonC commented 9 months ago

@magnanimous123 if you want to try doing the file export method above, but instead export to your desktop rather than directly to the Applications folder. Try running it then from the desktop. Hopefully you will get both messages if you follow the above screenshots - if it works, then move finally to the Applications folder. Try and let me know how you get on…

holovicc commented 7 months ago

I could not get it working either... -25211 is what i get still, regardless where i save.

bkromrey commented 7 months ago

Likewise, I cannot get the second pop up to appear so that I can allow the Automation when saving the script as an application in the Applications folder. Running Sonoma 14.4.1. The second pop up did appear when I saved the script as an application on my desktop. Thank you for your work on this!

MrSimonC commented 7 months ago

Apologies for checking but thanks for being thorough and ensuring it works by the desktop route… Annoying but glad we have a work around at least! I'm gonna close this issue for now.

darwinguz commented 2 months ago

in my case, i had to create an empty script, copy the script, and export (following readme) but with a different previous exported name and done