Years ago, I think in this forum, a helpful member offered this method to detect whether the option key is pressed:
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSAlternateKeyMask '") > 1 then etc.
If I remember correctly, Apple has warned that python will not be installed in some future version of macOS. Is there an alternative to python for this? I found this method:
… on this page:
The full script on that page works perfectly, but I haven’t been able to figure out how to adapt one of the single-line command for testing the Option key state into an AppleScript or whether it’s possible to do so.
Any help or advice would be gratefully received.
EDIT: I see that I can create this shell script and then “do shell script etc” from an AppleScript, but I would be glad to know how to incorporate the code directly into the AppleScript: