Applescripting-向下箭头,在Photoshop CS5选择文件窗口中高亮显示并选择文件

Applescripting-向下箭头,在Photoshop CS5选择文件窗口中高亮显示并选择文件,applescript,photoshop,Applescript,Photoshop,您好,谢谢您的帮助 我正在编写一个脚本,通过访问Adobe action脚本来编写一长串文件格式 我的问题是,一旦文件在photoshop的“选择文件”窗口中,我似乎无法访问脚本中带有向下箭头的文件 我会让它按路径打开一个特定的文件,但这个文件名会不断更改 这是我的 tell application "Adobe Illustrator" do script "eps format save" from "Default Actions" without dialogs end tell del

您好,谢谢您的帮助

我正在编写一个脚本,通过访问Adobe action脚本来编写一长串文件格式

我的问题是,一旦文件在photoshop的“选择文件”窗口中,我似乎无法访问脚本中带有向下箭头的文件

我会让它按路径打开一个特定的文件,但这个文件名会不断更改

这是我的

tell application "Adobe Illustrator"
do script "eps format save" from "Default Actions" without dialogs
end tell
delay 2
tell application "Adobe Photoshop CS5"
set myFile to (choose file) as string
open file myFile
delay 4
tell application "System Events"
    key code 125 -- **DOES NOT KEY DOWN**
            key code 36  -- **FOR SELECTING THE CHOOSE BUTTON ONCE HIGHLIGHTED**
end tell
    delay 4
tell current document
    do action "saving formats" from "Default Actions" -- action and set name,     case sensitive
end tell
end tell
说实话,我希望它能打开它所在文件夹指定路径内的任何文件,这样以后就不会出现问题


谢谢你的帮助

你不能照你说的做。首先,关于选择文件对话框,它不是“photoshop”选择文件对话框。这是一个applescript对话框。不管你把它放在photoshop的tell代码块中,applescript执行的是命令而不是photoshop

-- do illustrator stuff here

do shell script "/usr/bin/osascript -e 'delay 3' -e 'tell application \"System Events\"' -e 'key code 125' -e 'delay 0.2' -e 'key code 36' -e 'end tell' > /dev/null 2>&1 &"
set myFile to (choose file) as string

tell application "Adobe Photoshop CS5"
    open file myFile
    -- do photoshop action stuff here
end tell
其次,当“选择文件”对话框打开时,整个脚本将暂停,等待您在对话框中实际选择文件。因此,按下向下箭头的系统事件代码直到对话框关闭后才会执行。因此,在显示对话框时不会运行系统事件代码

一般来说,您的整个方法都不起作用。为了说明注意事项,这是行不通的。在运行系统事件代码之前,必须手动选择该文件

set myFile to (choose file) as string

tell application "System Events"
    key code 125
    delay 0.2
    key code 36
end tell

return myFile
但是有一个技巧你可以使用。我们可以在显示“选择文件”对话框之前发出系统事件代码,使该代码在运行前延迟3秒,然后当它确实运行时,将影响“选择文件”对话框。我们可以通过shell运行系统事件代码来实现这一点。试试这个

do shell script "/usr/bin/osascript -e 'delay 3' -e 'tell application \"System Events\"' -e 'key code 125' -e 'delay 0.2' -e 'key code 36' -e 'end tell' > /dev/null 2>&1 &"
set myFile to (choose file) as string
return myFile
现在我们可以把它放在脚本中,在photoshop中打开所选的文件

-- do illustrator stuff here

do shell script "/usr/bin/osascript -e 'delay 3' -e 'tell application \"System Events\"' -e 'key code 125' -e 'delay 0.2' -e 'key code 36' -e 'end tell' > /dev/null 2>&1 &"
set myFile to (choose file) as string

tell application "Adobe Photoshop CS5"
    open file myFile
    -- do photoshop action stuff here
end tell

我试图分析你的问题,但你的帖子让人困惑。你能准确地解释一下吗:-illustrator操作正在做什么(或者它保存了什么--它是输出一个修改过的文件名,还是一个特定的文件名?)-当Photoshop打开文档时(只是打开,打开一个特定的页面,或者--我的意思是在操作之前),你希望Photoshop做什么?我很确定你不需要系统事件关键代码,但我需要更多信息。