Creating a custom service with AppleScript

Hello to all,

I’m a complete beginner with AppleScript and Automator (but have managed to figure out how to do a couple of things) and hope that someone can help me with a small project I’m working on.

I use a piece of computer aided translation software called OmegaT. One of the functions it can perform is to auto submit a Google Translate suggested translation for a sentence by pressing cmd+M and then hitting Return.

This can be very handy when it comes to some texts, not very good with others (for instance, lists of ingredients or corporate offices and titles).

What I would like to do is create an AppleScript that can be used as a service on my MacBook Pro that will carry out a cmd+M then Return until the end of the document is reached and then stop.

I’ve managed to dig around and find bits and pieces for the following code which does one cmd+M and Return, but that’s it. I’m stuck on what I need to either:

  1. Make a dialog box pop up that allows me to enter the number of times I want the script to carry out these two commands

or

  1. Will somehow be able to tell how long the file is and run to the end and then stop

Here is the code I’ve put together so far:

tell application “System Events”
keystroke return
delay 0
tell application “OmegaT 2.1.7”
activate
end tell

set temp to display dialog “Enter total number of segments” default answer “”
set text_user_entered to the text returned of temp
set variable1 to the text item of text_user_entered
key code 46 using command down
tell application “System Events”
keystroke return
end tell
end tell

I’m afraid that’s as far as I’ve got. I’m not a programmer, so don’t really understand what I should be doing next.

I hope someone can advise further as this would be a really useful tool with regard to this software.

Thanks in advance,

Bowjest

Model: MacBook Pro
AppleScript: 2.1.2
Browser: Firefox 3.5.11
Operating System: Mac OS X (10.6)