要使用Karabiner-Elements将应用程序键映射到右键单击,可以使用:
"simple_modifications": [
{
"from": {
"key_code": "application"
},
"to": {
"pointing_button": "button2"
}
},但是,这将在鼠标指针所在的位置执行右键单击。我希望它将指针移动到插入符号所在的位置,然后执行右键单击。
想必,我需要使用"complex_modifications" rule来完成此操作。
我的主要问题是我不知道如何将鼠标指针位置更改为插入符号位置。使用AutoHotkey这里有一个答案,Moving the mouse pointer to the cursor
我不能说我真的理解那里的答案,但不管怎样,我希望用Karabiner-Elements来做这件事
发布于 2021-10-19 16:15:06
我认为你可以在更新的Karabiner-Elements的13+版本中将鼠标移动到指定的位置(我不能在MacOS High Sierra中使用它)。
但是我担心,首先很难得到一个选择的x和y的值。
但是:
您可以使用AppleScript UI attribute "AXFocusedUIElement"右键单击选定的UI元素。
(这确实适用于Finder窗口文件和文件夹以及TextEdit选择,但遗憾的是,不适用于Finder桌面上的Safari选择和文件。)
如果你的主要目标是在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快捷键更改为您喜欢的任何快捷键。)
https://stackoverflow.com/questions/63395636
复制相似问题