including a script into an app

Hi there !
As a new AppleScript user, I’m trying to script an action that should be done every time I launch Final Cut Pro. (change my network configuration).

The script below works great but for that, I have to create a new application called “final cut pro 4” that is in fact my own script saved as an app.

on run
tell application “Finder”
end tell
tell application “System Events”
tell process “finder”
tell menu bar 1
tell menu bar item “apple”
tell menu “apple”
tell menu item “configuration réseau”
tell menu “configuration réseau”
click menu item “fcp”
end tell
end tell
end tell
end tell
end tell
end tell
end tell
tell application “Final Cut Pro 4”
end tell
display dialog "n’oubliez pas de choisir votre dossier de travail dans:

→ menu final cut pro
→ réglages système"

tell application "Final Cut Pro"
end tell

end run

The problem is that it works when I launch FCP using this app (FCP 4) whereas I doesn’t when FCP is launched when clicking a document made with FCP (of course ! it calls FCP and NOT FCP 4 !)

What can I do to have this script included IN Final Cut Pro ? (that seems to be the base of scritpting to me but I just don’t know how to finalize such scripts…)

Thank you for your help…
(excuse my english, as you could have seen, I’m a frenchie…)

It is not possible to do what you want.

It is possible to ‘include the script in the application’ by Ctrl-Clicking the Final Cut Pro application in the Finder and choosing ‘Show Package Contents’ to see the application components (resources, internationalization/localization strings, etc.). You can then drop your script into one of the application’s folders, but it won’t make any difference.

Unless the application is programmed to look for the script and run it when the program launches, it will just be ignored.

There is currently no way to do what you describe (run a script automatically when you launch an app) unless the developer has provided some way of doing it.

The only alternative is some kind of background/idle script that periodically checks whether FCP is running and changes the network config accordingly, but it’s an ugly hack.

Tkanks for your reply, I think I will keep going on with my script…

I don’t understand why you say that doing this is a hack ?