Automator 到 Applescript 以编辑代码 [英] Automator to Applescript for Editing Code
问题描述
只是想知道是否可以将 Automator 中的watch me do"事件转换为 applescript,然后编辑生成的代码?我有一个在 Google 中输入查询(即 Apple1)的录音,但我希望该查询为录音的每个循环增加 ++,所以结果是 Apple1,那么下一个循环将是 Apple2、Apple3等.我知道增量在编程中是基本的,但我不确定如何使用 Automator 和/或 applescript 来做到这一点.任何帮助将不胜感激.
Just wondering if I can convert a "watch me do" event in Automator to applescript and then edit the resulting code? I've got a recording of entering a query (i.e. Apple1) into Google, but I'd like the query to increase ++ for each loop of the recording, so the result is Apple1, then the next loop would be Apple2, Apple3, etc. I know increments are elementary in programming, but I'm just not sure how to do it using Automator and/or applescript. Any help would be greatly appreciated.
推荐答案
在 Applescript 中完成这一切可能更简单.
It may be simpler just doing it all in Applescript.
示例:
set counter to 0
set theTerm to "apple"
repeat 4 times
set counter to counter + 1
open location "http://www.google.co.uk/#hl=en&output=search&sclient=psy-ab&q=" & theTerm & counter
end repeat
运行此代码将使您的浏览器打开对 apple1 到 4 的新搜索
Running this code will have your browser open a new search for apple1 through 4
更新:回复评论请求:
此示例向您展示了如何搜索谷歌图片并使用不同的术语和数字随机化搜索.
This example shows you how to search google images and randomise the search using different terms and numbers.
set theTerms to {"apple", "orange", "banana", "pear"}
set termCount to count of theTerms
set searchLoc to "http://images.google.com/search?hl=en&site=&tbm=isch&source=hp&biw=2171&bih=1062&q="
repeat 4 times
set termRandNumber to random number from 1 to termCount
set randomSuffixNumber to random number from 1 to 7000
open location searchLoc & item termRandNumber of theTerms & randomSuffixNumber
end repeat
这篇关于Automator 到 Applescript 以编辑代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!