Finder applescript:奇怪的行为

发布于 2024-08-23 04:48:56 字数 475 浏览 5 评论 0原文

我使用的是 OSX Snow Leopard(不过,我在 Leopard 上也遇到了同样的问题..) 这是AppleScript:

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窗口,但在实际移动之前,通过按向下箭头(我在列表视图中)前进到下一个文件,这样我每次都不会丢失我的位置移动一些东西。

问题是:它每隔一段时间就会起作用!实际上你必须执行两次才能使其工作!

有人有主意吗?

I'm on OSX Snow Leopard (I had the same issue on Leopard, though..)
This is the applescript:

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

It moves the current selection to the second Finder window, but before actually moving it advances to the next file by pressing arrow down (I'm in list view), so that I don't lose my position everytime I move something.

Problem is: it works every other time! You actually have to execute it twice to make it work!!

Anyone has an idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陈年往事 2024-08-30 04:48:56

尝试添加:

tell application "Finder" to activate

作为第一行。

Try adding:

tell application "Finder" to activate

as the first line.

冷月断魂刀 2024-08-30 04:48:56

我唯一的测试是将其保存为应用程序并从 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

My only testing was saving it as an app and launching it from the Dock, but by merely incorporating Paul's activate suggestion (and blocking them all into one tell for fun), I could not get this code to fail or require two clicks:

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文