applescript - AppleScript 移动鼠标并单击 Photoshop 中的特定元素
问题描述
我的脚本需要一点帮助。实际上,我不确定问题是否出在脚本中,或者我的概念是错误的。所以,我想要实现的是在 Photoshop CS6/Cloud 中自动在两个特定位置(收缩然后展开特定选项卡)上单击鼠标。然后将鼠标返回到原始位置。
我正在使用 MouseTools,当脚本没有应用在 Photoshop 中但在桌面上时,它可以正常工作。实际的问题是由于某种原因在 Photoshop 中没有执行鼠标点击。实际上,他们有时会,但很少。鼠标定位没有问题..只需点击即可。这是我到目前为止写的:
set mouseToolsPath to (path to home folder as text) & "UnixBins:MouseTools"
set {x, y} to paragraphs of (do shell script quoted form of POSIX path of mouseToolsPath & " -location")
-- saves the original coordinates in two variables
set z to x
set zz to y
tell application "Adobe Photoshop CS6"
activate
delay 1
set x to 1838
set y to 463
do shell script quoted form of POSIX path of mouseToolsPath & " -x " & (x as text) & " -y " & (y as text) & " -leftClick"
set x to 1799
set y to 463
do shell script quoted form of POSIX path of mouseToolsPath & " -x " & (x as text) & " -y " & (y as text) & " -leftClick"
set x to z
set y to zz
-- returns the mouse in original position
do shell script quoted form of POSIX path of mouseToolsPath & " -x " & (x as text) & " -y " & (y as text)
end tell
我有一种感觉,我正试图欺骗我在桌面上的 MouseTools,它被窃听了。
我已经用 Keyboard Maestro 试用版解决了这个问题,它工作得很好..但是因为我买不起专门针对这个问题的宏程序..我想写一个脚本..ofc 获得一些经验我。:)
编辑:为了完成这篇文章..对我来说这个问题的临时解决方案是“MouseTools”和“Cliclick”的组合。它在 10 次中的 9 次中有效,并且出于某种原因,仅当我通过“脚本编辑器”生成的可执行文件运行代码时。“Automator”只有在从 Automator 的 GUI 内部启动时才能正常运行。Automator 可执行文件无法正常运行..由于某种原因。真的很奇怪和错误的行为,可能会及时让我失望..但现在仍然有点工作。
set mouseToolsPath to (path to home folder as text) & "UnixBins:MouseTools"
set {x, y} to paragraphs of (do shell script quoted form of POSIX path of mouseToolsPath & " -location")
tell application "Adobe Photoshop CS6"
activate
delay 1
do shell script "/usr/local/bin/cliclick c:1838,463"
delay 0.5
do shell script "/usr/local/bin/cliclick c:1660,463"
end tell
delay 0.5
do shell script quoted form of POSIX path of mouseToolsPath & " -x " & (x as text) & " -y " & (y as text)
解决方案
推荐阅读
- django - Django在查询集中过滤重复的Obj
- flutter - 冻结的构造函数初始化器
- python - pip 安装后没有名为“PIL”的模块
- javascript - 将一个数组的索引附加到另一个数组的索引
- ruby - 我正在尝试编写一个程序来找到 2 个整数的最大回文乘积,Ruby
- java - 如何添加按钮以调用java方法
- css - React - Electron,使用 React-Quill 包,其样式不适用于组件
- python - PySImpleGUI -> 如何在后台播放音频
- android - 如何在 Spinner (android Kotlin) 中实现 For 循环逻辑
- node.js - 当错误出现时,我的代码不会进入节点 js 中的 else 块