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

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

问题描述

您好,感谢您的任何帮助,

Hello and Thank you for any help whatsoever,

我正在编写一个脚本,通过访问 Adob​​e 动作脚本来编写一长串文件格式.

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 对话框.你在 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.

Second, when the choose file dialog is open the entire script pauses waiting for you to actually choose a file in the dialog.所以按下向下箭头的系统事件代码直到对话框被关闭后才会执行.因此,显示对话框时不会运行系统事件代码.

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.

总的来说,您的整个方法都行不通.为了说明这一点,这是行不通的.您必须在系统事件代码运行之前手动选择文件.

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

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

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天全站免登陆