Looping AppleScripts

bowjest

Registered
Hi,

I've managed to find enough info via Google to get part of an AppleScript done that I really need.

I use a translation software package called OmegaT. When translating, you can opt to auto insert a Google Translation suggestion by pressing the key combination cmd+m.

If you then hit return, it moves to the next line and you can continue to auto fill via cmd+m.

I'd like to set up an AppleScript that when run will do both of these in turn until it reaches the end of the given doc and then quit.

Here is what I have so far (borrowed and amended from a couple of different places):

tell application "System Events"
keystroke return
delay 0
tell application "OmegaT 2.1.7"
activate
end tell
key code 46 using command down
tell application "System Events"
keystroke return
end tell
end tell

Can anyone tell me how I fit in a while loop that runs only until the end of the document has been reached and then stops issuing the "cmd+m/return" command?

Thanks
 
Ok, how about this - I found some code to bring up a dialog box so I can enter the number of times I want the cmd+m/return thing to run. The problem is, I can't figure out how to get the loop to work. Here is what I have:

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

In a shell script the loop would work something like this:

repeat while variable1 > 0
<COMMAND TO RUN>
set variable1 to variable1 - 1
end repeat

Can anyone advise on how to get this up and running? I think I've dug out all the required parts, I just can't figure out how to piece them together.

Thanks
 
Back
Top