Last active
March 16, 2023 14:30
-
-
Save vitorgalvao/6663126 to your computer and use it in GitHub Desktop.
Make right-clicking on OSX accessible via a keyboard shortcut
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
A [native solution][1] exists but it suffers from a major flaw: it right-clicks where the cursor is, not what on the selection. | |
This code addresses that limitation, though it only works on Finder windows and not the Desktop. | |
You can install it as a [Finder Service, and later asign it a keyboard shortcut][2]. | |
[1]: http://stackoverflow.com/questions/9171613/right-click-shortcut-for-mac-lion-os | |
[2]: http://www.macosxautomation.com/services/learn/tut01/index.html | |
*) | |
tell application "Finder" | |
if not frontmost then tell me to error "Finder is not the frontmost app" | |
set selected_items to the selection | |
if selected_items is {} then tell me to error "Nothing selected!" | |
set on_desktop to (insertion location as alias) is (path to desktop folder) | |
end tell | |
tell application "System Events" to tell process "Finder" | |
if on_desktop then | |
tell group 1 of scroll area 1 to tell (image 1 whose value of attribute "AXFilename" is the name of (item 1 of selected_items)) to perform action "AXShowMenu" | |
else | |
tell value of attribute "AXFocusedUIElement" to perform action "AXShowMenu" | |
end if | |
end tell |
How are you executing the command? I'm using Raycast
Wierd it works everywhere else in column view but on in list view in my downloads folder
Through Alfred. The Workflow has worked fine for eight years.
If anyone is having problems with the script there seems to be a conflict with using the tab view in finder with Raycast (macOS 11.4). I haven't checked if the script works in Script Kit but as mentioned in the thread above Alfred seems to be working solidly.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I see no reason why that would be the case (it’s just another Finder directory, it’s not special), neither can I reproduce (it works fine for me).