launch program and resize the window

I have written the following automator script which will be saved as a service.

I am trying to launch a program which is a windows program running under crossover.

The launch application works find. I then pause 10 seconds to wait for the program to be fully loaded then I try to run the following applescript.

on run {input, parameters}

set the_application to {path to frontmost application as Unicode text}
tell the_application
	set bounds of window 1 to {1, 1, 1281, 721}
end tell

return input

end run

I get the following error messages in the log:

Launch Application completed
Pause completed
Run AppleScript failed - 1 error
Can’t get window 1 of (“Macintosh HD:Applications:RootsMagic.app”)

First I need to get the service running then is there a way to pause until the application is loaded rather than waiting for a time period?

Thanks for any help or suggestions.
Roger

this is what I use with TextEdit


tell application "TextEdit"
	activate
	make new document
	set bounds of first window to {10, 100, 666, 444}
end tell

Thanks for the help.

It works find for TextEdit but will not work with RootsMagic.

It opened the program but then got an error message “RootsMagic got an error: Can’t set bounds of window 1 to {10, 100, 666, 444}.” at the set bounds statement.

I suspect it has something to do with the fact that RootsMagic is running under crossover but I am not sure at this point.

Roger