Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Launching an app with an AppleScript

Launching an app with an AppleScript
Thread Tools
SYN
Senior User
Join Date: Oct 2000
Location: Paris, France
Status: Offline
Reply With Quote
Dec 17, 2003, 02:10 PM
 
I've written a little Applescript that writes to a file's .plist file, launches the app, and quits.

the problem I have is that the AppleScript doesn't seem to quit, and so the menubar doesn't seem to appear on the app it is launching (it appears if the app is launched normally). It seems the AppleScript isn't giving hand to the app.

Any help would be greatly appreciated, I'm barely beginning here...

here's the code:

on run {}

set this_story to "<dict>
<key>SplashOrNot</key>
<string>NO</string>
<key>LanguageOfChoice</key>
<string>Francais</string>
<key>CardNumber</key>
<string>Reticulaires</string>
<key>NavigationOrNot</key>
<string>NO</string>
</dict>
</plist>"
set this_file to (((path to preferences folder) as text) & "diff.plist")
my write_to_file(this_story, this_file, false)
try
tell application "diff2"
run
end tell
end try
end run

on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as text
set the open_target_file to ¬
open for access file target_file with write permission
if append_data is false then ¬
set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file
Soyons Réalistes, Demandons l'impossible
     
Fresh-Faced Recruit
Join Date: Dec 2003
Status: Offline
Reply With Quote
Dec 17, 2003, 03:07 PM
 
This looks suspect to me:

Code:
try tell application "diff2" run end tell end try end run
The first thing is that it's improperly nested - if "run" begins inside a "tell" statement, it needs to end inside the same "tell" statement.

I'm also not sure that "run" needs an "end run" command at all - but I don't know enough about Applescript either to be sure.

hth,
-N
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Dec 17, 2003, 05:00 PM
 
isn't it:

Code:
tell app "foo" to activate.
or

Code:
tell app "foo" activate end tell
You know it makes sense. ☼ ☼ ☼ Growl.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:34 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2