首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Karabiner-Elements将应用程序键映射为在插入符号位置单击鼠标右键

使用Karabiner-Elements将应用程序键映射为在插入符号位置单击鼠标右键
EN

Stack Overflow用户
提问于 2020-08-13 20:53:48
回答 1查看 177关注 0票数 3

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

代码语言:javascript
复制
"simple_modifications": [
    {
        "from": {
            "key_code": "application"
        },
        "to": {
            "pointing_button": "button2"
        }
    },

但是,这将在鼠标指针所在的位置执行右键单击。我希望它将指针移动到插入符号所在的位置,然后执行右键单击。

想必,我需要使用"complex_modifications" rule来完成此操作。

我的主要问题是我不知道如何将鼠标指针位置更改为插入符号位置。使用AutoHotkey这里有一个答案,Moving the mouse pointer to the cursor

我不能说我真的理解那里的答案,但不管怎样,我希望用Karabiner-Elements来做这件事

EN

回答 1

Stack Overflow用户

发布于 2021-10-19 16:15:06

我认为你可以在更新的Karabiner-Elements的13+版本中将鼠标移动到指定的位置(我不能在MacOS High Sierra中使用它)。

但是我担心,首先很难得到一个选择的x和y的值。

但是:

您可以使用AppleScript UI attribute "AXFocusedUIElement"右键单击选定的UI元素。

(这确实适用于Finder窗口文件和文件夹以及TextEdit选择,但遗憾的是,不适用于Finder桌面上的Safari选择和文件。)

如果你的主要目标是在Finder的窗口中导航,这个脚本*可以完美地工作。

代码语言:javascript
复制
{  "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快捷键更改为您喜欢的任何快捷键。)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63395636

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档