Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
You can run AppleScript in Automator, but you can't edit an Automator action in AppleScript (unless that action was originally written in AppleScript and hasn't been saved as a compiled programme). – Mark Mar 21 at 9:40
Actually you can. After you run a "watch me do." you can select all the commands and paste them into a Applescript Doc. But in my opinion it is a waste of time in most cases because the code is normal GUI commands. I.e click this or that. – markhunte Mar 25 at 23:05

1 Answer

up vote 2 down vote accepted

It may be simpler just doing it all in Applescript.

Example:

   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

Running this code will have your browser open a new search for apple1 through 4

Update: Response to Comment request:

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
share|improve this answer
wow that's brilliant and works perfectly. the only problem is that i've tried changing the address "google.co.uk"; to "images.google.com"; but it seems to want to load the former anyway. any idea how to get it to open the images section? thanks again amazingly helpful – Peter Mar 25 at 19:34
also, not to push it, but any way to randomize the prefix and number suffix? in other words, scroll through a variety of words, such as apple, orange, banana and choose one and pair it with a randomly generated number such as 0013, 6593, 45, 2, etc. etc. thanks again and sorry to ask so much – Peter Mar 25 at 19:36
Updated per your request. – markhunte Mar 25 at 23:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.