Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Lorz

macrumors newbie
Original poster
Nov 4, 2021
24
1
Hello!
I would like to create a hotkey for "context menu" alias the "right click on mouse".
Somebody wrote a script for that:
https://forum.keyboardmaestro.com/t/click-mouse/15450
I have no experience with AppleScript. But I copied this into AppleScript. When I'm running it an error message pops up
1644688402184-png.357679

I'm sorry to show this in german. But it means: "System Events" has received an error. (...)"Script Editor" can not be read.

Is there anybody who can help me with that?
 

Slartibart

macrumors 68040
Aug 19, 2020
3,140
2,815
tell application "Finder" set sel to get the selection if (sel is {}) then log "Nothing selected! Can't proceed" return end if set target_item_name to the name of (item 1 of sel) end tell tell application "System Events" tell process "Finder" tell group 1 of scroll area 1 set target to the first image whose value of attribute "AXFilename" is target_item_name tell target to perform action "AXShowMenu" end tell end tell end tell

will bring up the context menu for the currently selected file on the desktop.

EDIT: action AXShowMenu shows the right-click menu
 

Lorz

macrumors newbie
Original poster
Nov 4, 2021
24
1
Thanx to @Slartibart
I get this
1644785294384.png

Sorry for including some german again. Error says
""System Events" received an error. Script Editor has no authorization for helpacces."
Do I have to change anything in system preferences?
 

Lorz

macrumors newbie
Original poster
Nov 4, 2021
24
1
One Question - Safety First - how to stop script? Or: Do I have to reactivate the script after restart?
 

Slartibart

macrumors 68040
Aug 19, 2020
3,140
2,815
One Question - Safety First - how to stop script? Or: Do I have to reactivate the script after restart?
not sure wether I get this - the script exits/ends when finished. if you bind it to a hotkey it will be possible to execute it on a selected item.
I don’t know how you want to implement keyboard hot key binding, but the script itself will do what’s written.
If you want to understand what’s happening I suggest stepping through it and use it as a service (System Preferences > Keyboard > Shortcuts > Services), but apparently you have some other intended use case - your original post refers to a keyboardmaestro script.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.