在第一个 运行-through 之后,AppleScript 重复循环变慢

AppleScript repeat loop gets slower after the first run-through

正在做一个项目 rn 并试图找出为什么在第一个 运行 之后整个事情会显着变慢。

keycode 6 使用 {shift down} 是告诉另一个程序执行的快捷方式。当我 运行 脚本时一切正常,但第二次重复整个程序的执行速度要慢得多。但是,如果我实际按下键盘上的快捷键,执行速度与第一个 运行 一样快。 所以我不知道是什么原因造成的,我真的需要它保持稳定。什么是最好的解决方案。尝试了不同的东西,比如击键(键码 6 使用 {shift down}),或者击键 "z" 使用 {shift down} 甚至

键下移 关键代码 6 上移键

none 其中有效...

代码如下:

set filepath to (path to me as string) & "Contents:Resources:main.MurGaa"

tell application "Finder"
open alias filepath
end tell



display dialog "How many profiles do you wanna scrape?" default answer "4000"
set banana to text returned of result
set apple to banana / 50

set progress total steps to apple
set a to 0
set progress completed steps to 0
set progress description to "Scraping..."

repeat apple times

set progress additional description to " profiles scraped: " & (a * 50) & " of " & banana
set progress completed steps to a

tell application "System Events"
    with timeout of 300000 seconds
        key code 6 using {shift down}
        delay 300
    end timeout
end tell

set a to a + 1

end repeat

display dialog "Done! Profiles scraped:" & banana

display dialog "If you want to scrape more profiles just restart the app"

quit

因此,经过反复试验后,我发现是我触发的另一个程序变慢了,因为 window 未激活。所以在 Auto Clicker 的设置中,这个功能总是放在前面。我检查了那个,现在一切正常。剧本也。

感谢大家的帮助。