鼠标在Mac上点击脚本

时间:2018-03-29 12:51:11

标签: macos terminal macros click applescript

尝试映射遥控器以便我可以使用它来操作我的音乐软件,为此我希望能够移动鼠标并单击它。我发现的所有解决方案(例如MouseTools,AppleScript内置点击功能,Apple的辅助功能" MouseKeys"点击键功能)似乎都过于关注层,窗口尝试将点击汇集到应用程序并询问它想要做什么。宣告了一个AppleScript错误"无法点击。"

我的问题是,终端命令/ AppleScript功能是什么,我可以使用它来做一个简单的,正常的点击,就好像我是从触控板上做的那样 - 如同点击,它没有关心什么'在下面,但只是做它并处理后果(打开窗口,选择窗口,任何东西,我不在乎,但我只是希望它通常点击,就好像它实际上是一个物理触控板点击)。

我的头发因为看起来苹果试图阻止任何软件解决方案做任何可能接近实际全球点击的事情。有解决方案吗谢谢:)

1 个答案:

答案 0 :(得分:1)

我建议下载AppleScript toolbox scripting addition.一旦安装在适当的位置,在Script Editor.app中,您就可以使用来自AppleScript工具箱字典的键和鼠标套件中的命令来... get,set,并单击鼠标位置(坐标)

以下是使用AppleScript工具箱词典

中的命令的示例代码

示例1

set mousePointLocation1 to {745, 110} -- The Collapsed Menu
set mousePointLocation2 to {780, 340} -- TV Link In The Menu
set mousePointLocation3 to {885, 180} -- Apple TV 4K Icon

delay 1 -- For Demonstration Purposes
activate application "Safari"
delay 1 -- For Demonstration Purposes

AST click at mousePointLocation1 ¬
    number of clicks 1

delay 1 -- For Demonstration Purposes

AST click at mousePointLocation2 ¬
    number of clicks 1

delay 1 -- For Demonstration Purposes

AST click at mousePointLocation3 ¬
    number of clicks 1

enter image description here

enter image description here

示例2

-- For Demonstration Purposes
-- Gives Me Time To Put The Mouse Where I Want
delay 3

-- Gets Coordinates Of The Current Mouse Location
set currentMouseLocation to AST mouse point location

-- Mouse Click At Defined Location
AST click at currentMouseLocation ¬
    number of clicks 2 -- How Many Clicks

enter image description here

示例3

set mousePointLocation to {20.0, 20.0}

delay 1 -- For Demonstration Purposes

AST set mouse point location mousePointLocation ¬
    without holding mouse down

delay 1 -- For Demonstration Purposes

AST click at mousePointLocation ¬
    number of clicks 1

enter image description here