1

在使用键盘导航 macOS Finder 时,我希望能够调出文件的上下文菜单。这通常通过执行鼠标右键单击来完成。这意味着我对如何仅使用键盘生成上下文菜单的搜索将我引向了 macOS 的鼠标键功能。这反过来又要求指针位于相关文件中。

我不想用键盘移动鼠标。我想绕过鼠标并完全右键单击,直接通过键盘拉出文件的上下文菜单。

这对Karabiner可行吗?如果是这样,怎么做?如果没有,我还可以通过什么其他方式实现这一目标?

4

1 回答 1

1

[虽然下面的脚本说明了KarabinerAppleScript的能力,但其中有一个Apple 提供的非常强大的功能:System Preferences > Keyboard > Keyboard > "Focus on …"它可以让你选择——除其他外—— Focus on Menu Bar(或类似的,用英语)。
通过激活它,接下来单击预设(行尾)快捷方式,您可以输入您喜欢的任何新快捷方式。]

如果您选择(移动到)您想要虚拟右键单击的文件,您可以这样做:

{  "description": "If in Finder click 'Ablage' …",
   "manipulators": [{
            "type": "basic",
            "from": {
                "key_code": "c",
                            "modifiers": { "mandatory": [
                                           "left_control", "left_shift" ] }
                    },
                      "to": [ { "shell_command": "osascript -e 'tell application \"System Events\" to click menu bar item \"Ablage\" of menu bar 1 of application process \"Finder\"'"
                            } ]
                    }]
}

该脚本不会打开上下文菜单,而是会打开包含相同信息的 Finder 的“文件”菜单!当然,您可以将我的快捷方式 (Ctrl-Shift-C) 更改为您喜欢的任何一个。

它假定(= 要求)Finder 位于最前面。(您必须将“Ablage”替换为英语或其他等效项:“File”?)
它使用由 osascript shell-command 触发的 AppleScript 命令。

(因此,您将获得一个 shell 命令:使用 Automator 记录任务 => 将其“图标”复制到 ScriptEditor => 将相关的“告诉应用程序……”字样复制到上面的 osascript 中。)

于 2021-10-17T10:00:39.363 回答