Applescripting - 向下箭头突出和一个Photoshop CS5中选择文件选择文件窗口 [英] Applescripting - down arrow to highlight and select file within a Photoshop CS5 choose file window

查看:112
本文介绍了Applescripting - 向下箭头突出和一个Photoshop CS5中选择文件选择文件窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,感谢您的帮助无论如何,

Hello and Thank you for any help whatsoever,

我写一个脚本通过访问的Adobe动作脚本编写的文件格式长长的清单。

I am writing a script to write a long list of file formats by accessing Adobe action scripts.

我的问题是,我似乎无法在脚本中访问一个文件有一个向下的箭头,一旦它在Photoshop的选择文件窗口。

My problem is that I cannot seem to access a file with a down arrow within the script once it is in a photoshop "choose file" window.

我将有它打开特定文件由路径,但该文件的名称就会不断地变化。

I would have it open a specific file by path but this file name will change constantly.

下面是我

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

和告诉你实话我很想为它指定的路径,它是在这样没有问题存在后的文件夹中打开的任何文件。

And to tell you the truth I would love for it to open any file within a specified path to the folder it is in so that there are no glitches later.

感谢您的帮助。

推荐答案

为你问你不能这样做。首先,关于选择文件对话框,它不是一个的Photoshop选择文件对话框。它是一个AppleScript对话框。不要紧,你有它code的Photoshop的诉说块内,AppleScript的是执行该命令没有的Photoshop。

You can't do as you ask. First, regarding the choose file dialog, it is not a "photoshop" choose file dialog. It is an applescript dialog box. It doesn't matter that you have it inside the photoshop tell block of code, applescript is executing the command not photoshop.

其次,当选择文件对话框打开整个脚本暂停等着你竟然选择在对话框中的文件。因此,系统事件code至preSS的向下箭头不会执行,直到关闭对话框后。这样的系统事件$时,对话框显示C $ c未运行。

Second, when the choose file dialog is open the entire script pauses waiting for you to actually choose a file in the dialog. So the system events code to press the down arrow does not execute until after the dialog box is dismissed. As such the system events code isn't run when the dialog is showing.

在一般你的整个做法是行不通的。为了说明这个通知将无法正常工作。您必须手动选择系统事件code将不能运行该文件。

In general your whole approach will not work. To illustrate notice this won't work. You have to manually choose the file before the system events code will run.

set myFile to (choose file) as string

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

return myFile

但是,你可以使用一个技巧。我们可以发出系统事件code之前显示文件对话框中选择,使该code延迟3秒钟的时间运行之前它,那么当它运行它将会影响选择文件对话框。我们可以通过在壳运行的系统事件code做到这一点。试试这个...

But there is a trick you can use. We can issue the system events code before the choose file dialog is shown, make that code delay 3 seconds before it is run, then when it does run it will effect the choose file dialog. We can do this by running the system events code through the shell. Try this...

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中打开所选文件。

So now we can put this in your script to open the chosen file in 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

这篇关于Applescripting - 向下箭头突出和一个Photoshop CS5中选择文件选择文件窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆