首页 > 解决方案 > 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)

标签: applescriptmouseoverphotoshop

解决方案


推荐阅读