3

要使用 Karabiner-Elements 将应用程序键映射到右键单击,可以使用:

"simple_modifications": [
    {
        "from": {
            "key_code": "application"
        },
        "to": {
            "pointing_button": "button2"
        }
    },

但是,这将在鼠标指针的位置执行右键单击。我希望它将指针移动到插入符号的位置,然后执行右键单击。
据推测,为此我需要使用"complex_modifications" rule.
我的主要问题是我不知道如何将鼠标指针位置更改为插入符号位置。使用 AutoHotkey 这里有一个答案 将鼠标指针移动到光标
我不能说我真的理解那里的答案,但无论如何我希望用 Karabiner-Elements 来做这个

4

1 回答 1

1

我认为您可以将鼠标光标移动到较新的 13+ 版本的 Karabiner-Elements(我不能与 MacOS High Sierra 一起使用)中的指定位置。
不过我担心,首先要获得选择的 x 和 y 值非常困难。

但是:
您可以使用 AppleScript UI 属性“AXFocusedUIElement”右键单击选定的 UI 元素。
(这确实适用于 Finder 窗口文件和文件夹以及 TextEdit 选择,例如,但遗憾的是不适用于 Safari 选择和 Finder 桌面上的文件。)
如果您的主要目标是在 Finder 的窗口中导航,则此脚本* 可以完美运行。

{  "description": "Right-click via Karabiner-Elements/shell-command/AppleScript",
   "manipulators": [ {
            "type": "basic",
            "from": {
                "key_code": "left_arrow",
                "modifiers": {"mandatory": "left_control" }
                    },
              "to": [  {
 "shell_command": "osascript -e 'tell application \"System Events\" to set _/¯
  activeApp to name of first process whose frontmost is true \n tell application _/¯
  \"System Events\" to tell application process activeApp \n set mySelect _/¯
  to value of attribute \"AXFocusedUIElement\" \n tell mySelect to perform _/¯
  action \"AXShowMenu\" \n end tell'"
}  ]  }  ]
}

请注意,整个 osascript ( "osascript -e ' ... >> ... end tell'" ) 必须是单行的(我插入了 "_/¯" 以提高可读性)。

(* AppleScript“tell application ... end tell”部分在网上有多种版本。
并且:当然,您可以将我的 Ctrl-LeftArrow 快捷方式更改为您喜欢的任何一个。)

于 2021-10-19T16:15:05.673 回答