【问题标题】:Finder applescript: Odd behaviourFinder applescript:奇怪的行为
【发布时间】:2010-02-22 09:33:54
【问题描述】:

我在 OSX Snow Leopard 上(不过,我在 Leopard 上遇到了同样的问题..) 这是小程序:

tell application "Finder" to set my_from to selection
tell application "Finder" to set my_to to target of window 2
tell application "System Events" to keystroke (ASCII character 31)
tell application "Finder" to move my_from to my_to

它将当前选择移动到第二个 Finder 窗口,但在实际移动它之前通过按下箭头前进到下一个文件(我在列表视图中),这样我每次移动时都不会丢失我的位置.

问题是:它每隔一段时间都有效!您实际上必须执行两次才能使其工作!

有人有想法吗?

【问题讨论】:

  • 我得到了这个:error "Finder got an error: Can’t get alias file \"\"." number -1728 from alias file ""。 ??

标签: macos scripting applescript finder


【解决方案1】:

尝试添加:

tell application "Finder" to activate

作为第一行。

【讨论】:

    【解决方案2】:

    我唯一的测试是将它保存为一个应用程序并从 Dock 启动它,但仅通过合并 Paul 的激活建议(并将它们全部屏蔽为一个有趣的提示),我无法让此代码失败或需要两次单击:

    tell application "Finder"
       activate
       set my_from to selection
       set my_to to target of window 2
       tell application "System Events" to keystroke (ASCII character 31)
       move my_from to my_to
    end tell
    

    【讨论】:

    • 如果你这么说,我将不得不调查真正的原因。如果我删除按键,一切都很好。所以它必须以某种方式连接到那个..
    猜你喜欢
    • 1970-01-01
    • 2015-05-30
    • 1970-01-01
    • 1970-01-01
    • 2017-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-12
    相关资源
    最近更新 更多