【问题标题】:Mouse Click Through Scripting on MacMac 上的鼠标单击脚本
【发布时间】:2018-03-29 12:51:10
【问题描述】:

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

我的问题是,什么是终端命令/AppleScript 功能,我可以使用它来进行简单、正常的点击,就好像我是从触控板上完成的一样 - 就像我在触控板上完成的一样,它是血腥的点击,而不关心下面的内容,但就是这样做并处理后果(打开窗口,选择窗口,任何事情,我不在乎,但我只想让它正常点击,就好像它实际上是物理触控板点击一样)。

我对此感到非常恼火,因为 Apple 似乎试图阻止任何软件解决方案执行任何可能接近实际全局点击的操作。有什么解决办法吗?谢谢:)

【问题讨论】:

  • 你应该问这个问题:apple.stackexchange.com
  • 您在使用 MouseTools 时遇到了哪些错误?我从未使用过它,但我以前见过它,它看起来应该完全符合您的要求:将光标移动到一个位置并单击该位置。文档没有显示任何关于图层或窗口的信息。

标签: macos terminal macros click applescript


【解决方案1】:

我建议下载AppleScript toolbox scripting addition. 一旦安装在正确的位置,在 Script Editor.app 中,您将能够使用 AppleScript 工具箱字典中的键和鼠标套件中的命令...获取、设置和单击在鼠标位置(坐标)

这是一些使用 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


示例 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


示例 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

【讨论】:

  • 安装它的正确位置是什么,我无法在 Script Editor.app 中创建 ScriptingAdditions 文件夹并将其移动到 /Library/ScriptingAdditions~/Library/ScriptingAdditions 仍然没有任何区别AST 命令无法识别?
猜你喜欢
  • 2011-12-30
  • 1970-01-01
  • 1970-01-01
  • 2013-09-29
  • 1970-01-01
  • 2017-12-11
  • 1970-01-01
  • 2011-06-18
  • 2019-07-07
相关资源
最近更新 更多