MrSimonC / Toggle-Mac-Function-Keys

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

AppleScript Switches to F Keys, but not back #18

Open gedeyenite opened 1 week ago

gedeyenite commented 1 week ago

This no longer fully runs as designed. It will switch my FKEYs to FUNCTION KEY MODE but not back to system controls, such as brightness, search, mic, and music controls.

When it executes, it stays on the System settings without closing the "application".

Sometimes, it appears to do nothing. CleanShot 2024-10-17 at 1129 35 (System Settings) - 009571

MrSimonC commented 1 week ago

Hey thanks for the issue / screenshot. I've checked on my Mac min M2 Pro and it's still working ok for me - so if you want to confirm a few things: If you go top Apple Menu, About this Mac, are you on Sonoma 14.6.1? Also, are you on a newer Mac than an M2? e.g. M3 MacBook (if so it might be a race condition) - possibly ...

Finally, just try pulling the code from this repo again: https://raw.githubusercontent.com/MrSimonC/Toggle-Mac-Function-Keys/refs/heads/main/Toggle%20Function%20Keys.scpt

and manually copy / paste into Script Editor and run and tell me how you get on - and if there are any errors in script editor? Thanks.

twfenwick commented 1 week ago

I had a similar and maybe same issue. M3 MBP Sonoma 14.6.1. It opened the dialog but didn't toggle either way and gave this error.

image

The option to add this app to Privacy & Security -> Automation -> Toggle Function Keys.app (turn on System Events) is not there, which might be the cause or a clue.

I was able to add the script as a "Run AppleScript" app and it works for me now.

  1. Open Automator app
  2. Click New Document
  3. Choose Application
  4. Find “Run AppleScript” and double-click or drag to the workflow window
  5. Select all the boiler plate code prefilled in the script box
  6. Paste the script exactly the same as from the original instructions (in Toggle Function Keys.scpt) over the boiler plate code
  7. File -> Export…
  8. Save the app with defaults:
    • I chose toggle-function-keys.app in case of conflict with the name from the original instructions.
    • Default save location for me was Automator — iCloud
    • Code Sign: Don’t Code Sign (only option)
image
  1. You may need to restart your computer for the app to show up in settings for the next step
  2. Open the app, acknowledge the security prompts and set:
    • System Settings -> Privacy & Security -> Accessibility
    • System Settings -> Privacy & Security -> Automation-> toggle-function-keys.app (turn on System Events)
gedeyenite commented 6 days ago

Thanks for the assistance. I tried setting it up as an app in Automator, but I get odd errors after allowing the various permissions that macOS asks for.

-Stephen

On Oct 19, 2024 at 11:04:50, Tim Fenwick @.***> wrote:

I had a similar and maybe same issue. M3 MBP Sonoma 14.6.1. It opened the dialog but didn't toggle either way and gave this error. image.png (view on web) https://github.com/user-attachments/assets/a71c58ef-9d0c-4ba6-9be7-f82598b033b0

The option to add this app to Privacy & Security -> Automation -> Toggle Function Keys.app (turn on System Events) is not there, which might be the cause or a clue.

I was able to add the script as a "Run AppleScript" app and it works for me now. image.png (view on web) https://github.com/user-attachments/assets/64fc4da1-dd44-412e-8bc4-50a1929e30ae

  1. Open Automator app

  2. Click New Document

  3. Choose Application

  4. Find “Run AppleScript” and double-click or drag to the workflow window

  5. Select all the boiler plate code prefilled in the script box

  6. Paste the script exactly the same as from the original instructions over the boiler plate code

  7. File -> Export…

  8. Save the app with defaults:

    • I chose toggle-function-keys.app in case of conflict with the name from the original instructions.
    • Default save location for me was Automator — iCloud
    • Code Sign: Don’t Code Sign (only option)
  9. You may need to restart your computer for the app to show up in settings for the next step

  10. Open the app, acknowledge the security prompts and set:

    • System Settings -> Privacy & Security -> Accessibility
    • System Settings -> Privacy & Security -> Automation-> toggle-function-keys.app (turn on System Events)

— Reply to this email directly, view it on GitHub https://github.com/MrSimonC/Toggle-Mac-Function-Keys/issues/18#issuecomment-2424092814, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEFFZCIXP7H47BBP5M2XDDZ4KGLFAVCNFSM6AAAAABQEH34NOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRUGA4TEOBRGQ . You are receiving this because you authored the thread.Message ID: @.***>