Applescript quicklook:箭头键向下1000次

时间:2015-06-16 00:06:01

标签: applescript arrow-keys quicklook

我是苹果剧本的初学者。

我想打开包含数百张照片的文件夹目录,并快速查看每张照片1秒,然后转到下一张(假设使用向下箭头/键代码'124')。

我不知道如何构建脚本。我试图从其他问题编译一些公式或使用手动rec但它不起作用。

谢谢!

1 个答案:

答案 0 :(得分:1)

尝试以下脚本。我把延迟时间延长了,所以你有时间停止脚本(测试它):

set timePerPreview to 5
set thisFolder to (choose folder with prompt "Pick the folder containing the files to process:") as string
tell application "Finder"
    activate
    open folder thisFolder
    select every item in folder thisFolder
    delay 2
    set fileCount to (count items in (get selection)) # (count files in folder thisFolder) is faster but counts also .DS_Store and other invisible files
    if fileCount = 0 then
        beep
        return
    end if
end tell

pressSpaceInFinder()

delay timePerPreview / 2 # first it has to open the window which seems to need a little time

repeat fileCount - 1 times # -1 because the first item is already displayed 
    delay timePerPreview
    # do shell script "sleep" & space & timePerPreview as text
    tell application "System Events"
        tell application process "Finder"
            set frontmost to true
            # cursor right = 124, left = 123
            key code 124
        end tell
    end tell
end repeat

delay timePerPreview

pressSpaceInFinder()

on pressSpaceInFinder()
    tell application "System Events"
        tell application process "Finder"
            set frontmost to true
            keystroke space
        end tell
    end tell
end pressSpaceInFinder

请注意,由于script每秒都会被激活,因此很难停止Finder。将看看我是否可以添加一个检查以查看预览窗口是否打开,如果没有,则停止脚本。

另外:(没有检查)脚本将在预览窗口打开之前运行,关闭它,但你可以按空格键再次打开它。

此外,第一部分(获取文件计数)不是很大,并且可能在延迟缩短时失败。我们可以扫描整个文件夹中的图像,只计算/选择它们(它有一个扫描仪的文件模板,请参见菜单File),但当然你可以删除整个计数的东西,只做repeat 1000 times