为 MacOS 工作(High Sierra,可能它也适用于较新的操作系统)
我从这里下载了文件AppleScript Toolbox.osax:https://astoolbox.wordpress.com/
将文件放入文件夹:/Users/me/Library/ScriptingAdditions
运行Automator 并启动一个新服务:
粘贴此脚本
activate application "Firefox" -- or "Safari" or "Chrome", etc
set mousePointLocation1 to {1700, 250} -- coordinates depend on your screen size
AST click at mousePointLocation1 number of clicks 1
然后保存:
转到Preferences > Keyboard > Services 并为此服务添加快捷方式
之后,您将在此处看到新的快捷方式:
在 Google 电子表格中,我按 F5,显示面板,然后按 ^F5,光标跳到此面板并单击。
我是 macOS 的菜鸟,我相信它可以做得更好。这就是我现在设法做到的方式。
脚本的另一种修改可能更方便:
activate application "Firefox"
tell application "System Events"
key code 96 -- this is F5 key
end tell
delay .5
AST click at {1700, 250} number of clicks 2 -- or 3 maybe
这样您就不需要按F5。只需按^F5 并继续。
有效
以防万一。如果你知道 Python。我已经设法使用 Python 模块pynput 按下F5 移动并单击鼠标:
from pynput import mouse, keyboard
k = keyboard.Controller()
k.press(keyboard.Key.f5)
k.release(keyboard.Key.f5)
m = mouse.Controller()
m.position = (1700, 240)
m.press(mouse.Button.left)
m.release(mouse.Button.left)
m.click(mouse.Button.left, 2)
https://pynput.readthedocs.io/en/latest/
可以这样转换成macOS Service:
然后您可以通过Keyboard > Services > Add Shortcut 以相同的方式运行此服务