![]() |
AppleScript: I want to quit the script editor.
Greetings,
I know nothing about AppleScripting and I'm under a serious time constraint, so don't have the time to learn what I need to learn to make it work the way I want, so I'm here begging some help off you already-experts. The Background: I am forced to force my users to use Lotus Notes on the Mac. Lotus Notes (6.5.2) has internal (very poor) handling of URLs. You can specifiy other browsers to use, such as IE (need I say anything more?), or Netscape (Classic only, don't you know), or "Other". Well, "Other" doesn't work for anything at all. So I decided to try and create a simple AppleScript that would open Safari and see if that would work. It does! The Script: tell application "Safari" activate end tell The problem is, it opens the Script Editor when it runs. And, I don't want it to open the Script Editor at all. I tried saving it as all the other options, but when any of the scripts/apps run, it either opens the Script Editor, or doesn't do anything at all. For example, I saved it as an Application. Then pointed Notes at it, I click on a URL link, and the script opens in the dock and then closes, Safari never actually opens. I tried adding some line that told the Script Editor to automatically quit, but I get an error saying that it cannot quit when it's running the script. Does anyone have any insight into this? Thanks! |
Applescript
Can you post the actual applescript? What options are you choosing when saving the script file?
irishOmac |
Lotus Notes cannot deal with "Application Bundles" so they don't work, and it won't even recognize "Script Bundles", so I'm left with "Script", "Application", and "Text".
script 1: Code:
tell application "Safari"script 2: Code:
tell application "Safari"It's quite frustrating. I'm guessing that for whatever reason, the problem is with Lotus Notes (hatehatehatehate). I can save the "script 1" as an app. Alone, the script works great, I can double click the .app and Safari opens. I can point Notes at the .app and when I click on a URL, the script runs (Script Editor does NOT open), and then quits, and Safari never opens. The only way I've gotten Safari to work so far is just saving it as a "Script" (or "Text"), and it doesn't matter if I choose "Run Only" or nothing at all as an option, I click on a link in Notes, Script Editor opens and runs the script, and Safari Opens. Script Editor stays open. My users will be confused, which I why I wanted Script Editor to go away. |
1 Attachment(s)
I have a script that will do exactly what you are looking for. I can't remember where I got it maybe from the Notes Forums. I have attached it to this note. Place the file somewhere on your mac and in the browser setting in Notes point to the script. Works great for me !.
Andrew |
Try this
tell application "Safari"
activate end tell delay 5 tell application "Script Editor" quit end tell You may need to adjust the delay time to make Lotus happy, but try that and see if it works. If it doesn't let me know irishOmac |
Thanks for the replies.
I had the same though and I'd already tried that but still got the error "The document can't be closed while the script is still running." I suppose I could call yet another applescript app to run and kill Script Editor? What a messy kludge though.. |
Applescript
You can put a script to open the script app in Lotus notes. When the lotus notes script calls the other script app that one can open Safari and close Script Editor if needed.
That is strange. |
Ah, ShuffleBear, thanks, I missed your post, that's exactly what I'm looking for!
The code for that script is: Code:
on open target_URL |
yellow:
I'm not sure I understand the problem, but if it is that Lotus Notes doesn't like executing .app bundles, maybe you could wrap your AppleScript into some other kind of executable. You could use one of the 3rd-party utilities that make double-clickable apps out of scripts but maybe you would have the same problems with the app that they create. But maybe just a shell script would work? You could run your AppleScript code from a Perl script for example by using something like what is shown in this old thread: http://forums.macosxhints.com/showth...04&#post131204 where you could use the runAppleScript function to run the AppleScript code as illustrated by the getSourceOfFrontWebPage and showWebpage functions in that example. |
I tried a shell script but couldn't get the URL passed to the script properly.
I thought about trying perl or java, but don't know jack about either. I'll give that thread a perusal and see if I can make it work for me. Thanks for the help all! |
Quote:
For a Perl script, they are $ARGV[0] $ARGV[1] etc |
Quote:
I was trying to echo $1 and pipe that into open -a "Safari". I also tried echo $1 and piped that into osascript. I think the echo is where I'm running afoul there. Safari opens but the URL isn't passed to it. |
Well, I figured out why an applescript.app wasn't working. Apparently Applescript is all F'd up. My simple applescript was running other applescripts instead. In this case, a colorsync applescript. When I removed that one, it moved on to "import email into Entourage". After removing that one, it started launching iTunes. You get the idea.
The ONLY way to make it work properly was to remove all other applescripts from the hard drive. Bizarre. |
Well from a command line, the echo with pipe doesn't work for me. However, the command
open 'http://www.google.com' opened Google in Safari (since Safari is my default browser). So maybe in the bash script it should be open $1 ? Just wild guessing here... |
Good idea..
Doesn't work ("Unable to launch program", same problem when trying to point it at a .app bundle). I tried some variations but it doesn't seem to like the $1 variable. |
Quote:
The following bash script (saved in a file named "open_this") works fine for me when I invoke it via the command (in Terminal): ./open_this http://www.google.com Code:
#!/bin/sh |
Yes, your script definitely works.
But it doesn't work with Notes. Looking back at what I fiddled with, it's all worthless uses of attempting to echo $1 and pipe it into open -a Safari, but the URL isn't passed.. Safari opens, but I'm getting the wrong info from $1. For example, Notes pointing at a script with: #!/bin/sh echo $1 > /Users/yellow/Desktop/test.txt And then clicking on the URL in Notes gives me: yellow% more test.txt -psn_0_53477377 |
Quote:
If you watch the output of 'ps axww' when Notes invokes the application/script, you will see that the "psn_xxxxx" is part of the command line. You need to find out which argument is the one containing the URL that you want. It probably is $2, but maybe there are other arguments we don't know about. Try the following script to find out: Code:
#!/bin/sh |
I tried that too.. and they were all blank, but I had only tried to $3, so I'll put in some more and see what comes out.
|
I tried all the way to $10 and got:
yellow% more test.txt arg1: -psn_0_54919169 arg2: arg3: arg4: arg5: arg6: arg7: arg8: arg9: arg10: -psn_0_549191690 |
If I go further, all I get are:
arg11: -psn_0_550502411 arg12: -psn_0_550502412 arg13: -psn_0_550502413 arg14: -psn_0_550502414 arg15: -psn_0_550502415 arg16: -psn_0_550502416 arg17: -psn_0_550502417 arg18: -psn_0_550502418 <sigh> Thanks for all the help! |
I did some googling and found a macosxhints article (which yellow has evidently seen since he added a comment to it today) and two Lotus Notes forum discussions:
http://www.macosxhints.com/article.p...30627172202953 http://www-10.lotus.com/ldd/nd6forum...5?OpenDocument http://www-10.lotus.com/ldd/nd6forum...0?OpenDocument The macosxhints article suggests a strange workaround - selecting a blank document file (instead of an application). Did you try this yellow? There is also a comment by someone who supplied a URL (no longer valid) for an AppleScript to make this work. The first of the Lotus forums links has an AppleScript from Lotus Support that people have apparently had success with. The second of the Lotus forums links has a submission by the same person who wrote the script mentioned in the comment to the macosxhints article. Yellow: I would go back to trying the straight AppleScript solution (save as Application) and contact Lotus support if it doesn't work. I don't understand why you would get all those "psn_xxx" arguments in the command line of the application invoked by Notes. Usually there is one such argument that I think indicates the process number for backward compatibility with Process Manager software (used in Classic). |
I wonder if part of this problem is the fact that Notes is a carbonized app..
|
Currently I'm using the AppleScript method, but I cannot save it as an app. I found out why. For whatever reason, when the app is invoked, it runs random applescripts. If I remove every other apple script from the Mac, the app runs great. I noted this a little further up in this thread.
http://forums.macosxhints.com/showpo...6&postcount=13 It's still not clear to me if this is a problem with Notes, or that Applescript is screwy. Someone mentioned something about prebinding, but that seems far-fetched to me. I talked with some other Mac heads who use Notes and they were all seeing the same thing. But for the moment, Applescript works, provided my users don't mind the script editor running. Thanks for the continued help! |
Quote:
But recalling what was said in that macosxhints article - that you could point Notes to a document file and it would work to run the application associated with that document - I'm thinking that what Notes might be doing is searching for an app with a specified creator code and then running that app. If this is the case, you might be able to solve your problem by saving your script as an application but then using one of the many 3rd-party utilities that can edit creator codes and change the creator code to something unique. You would do this before you point Notes to this app. That way (if my theory is right) it would be sure to run the correct AppleScript since only yours would have the creator code it was looking for. Quote:
This is similar to that described in this macosxhints article: http://www.macosxhints.com/article.p...00401270713117 where people seemed to identify the problem as related to the format used by Script Editor for compiled apps. They recommended removing the resource fork of the .app file |
yellow:
Quoting hayne - "I'm thinking that what Notes might be doing is searching for an app with a specified creator code and then running that app. If this is the case, you might be able to solve your problem by saving your script as an application but then using one of the many 3rd-party utilities that can edit creator codes and change the creator code to something unique. You would do this before you point Notes to this app. That way (if my theory is right) it would be sure to run the correct AppleScript since only yours would have the creator code it was looking for." Given the behavior yellow describes, hayne is likely on the right track to solving the problem for an AS application. Change the creator type (as he suggests) to a unique four character signature. If the app has a resource fork, open the app with a resource editor and set the BNDL signature to the same as the creator. Open the plst resource and scroll most of the way down til you find 'aplt' in the XML code. Replace 'aplt' with your unique signature. Save changes and point notes to the script app. Whut hoppen? For a script app with no resource fork, I think you change the .plist in the same manner as for the plst resource above... but I don't have much experience with app bundles. I _think_ Notes should be able to 'see' the recreatored app. Let us know if this works. Peter B. ----- |
Quote:
|
| All times are GMT -5. The time now is 05:37 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.