我们有一个用于Photoshop的自动化工具,它使用一个控制应用程序,叫做。
一种情况是我们必须在CameraRAW插件中打开一个原始图像,然后在Photoshop中打开它。这个部分是通过使用系统事件的applet来处理的。当该applet终止时,我们运行Photoshop的处理脚本。
由于有些图片需要相当长的时间才能打开,所以我们必须确保在脚本能够运行之前,图片确实是打开的。…这就是我被困的地方。
目前,我正在使用以下代码,以便等到图像打开( " open“的标准是正确的(并手动测试),所以这里不是问题所在)。
tell application "Adobe Photoshop CC 2015"
activate
tell application "System Events"
tell application process "Photoshop CC"
--
display alert "Waiting for Window"
--
repeat
try
set wn to name of window 1 as text
try
if (wn contains "(RGB/16") then
set wn to "image is open: " & wn
end if
end try
if (wn contains "(RGB/16") then
display alert "We are there, quitting now… " & wn
exit repeat
end if
end try
delay 1
end repeat
end tell
end tell
--
display alert "Ready for process"
--
-- and here comes the processing code
end tell我还尝试设置一个变量,该变量被测试为用于重复的参数,并在满足退出条件时进行更改。
试图在重复循环中创建偶数警报并不会产生任何效果;脚本以无限循环结束。
很有可能我错过了显而易见的…所以,我很感谢任何有帮助的提示。
提前谢谢。
发布于 2016-06-24 18:41:56
我认为您的脚本有几个小问题,导致了您的问题。
name of window 1时,您正在使用name of document 1。使用您的第一个try块,您没有意识到它实际上在name of window 1上产生了一个错误try块的修改示例脚本
tell application "Adobe Photoshop CC 2015"
display alert "Waiting for Window"
repeat
try
set wn to name of document 1 as text
on error
set wn to ""
end try
try
if wn is not equal to "" then
set wn to "image is open: " & wn
end if
end try
if wn is not equal to "" then
display alert "We are there, quitting now… " & wn
exit repeat
end if
delay 1
end repeat
display alert "Ready for process"
end tellhttps://stackoverflow.com/questions/38014507
复制相似问题