• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: panther weirdness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: panther weirdness


  • Subject: Re: panther weirdness
  • From: Graff <email@hidden>
  • Date: Fri, 14 May 2004 14:00:03 -0400

Ahh, my bad here. I saw the Java part and somehow missed the AppleScript part. I've never really combined the two so the combination got overlooked and I assumed that your message went to the wrong list.

Still, that simple AppleScript shouldn't be a problem. I entered your AppleScript into the Script Editor application and it ran just fine in every way I could discern. If there is a problem it's most likely in the Java code or in how Java accesses the AppleScript. I would still hit the Java list and see if anyone there has any experience in using AppleScript through Java.

Here is an article on using AppleScript in Java, is this where you got most of this script from?
<http://www.macdevcenter.com/pub/a/mac/2003/02/25/apple_scripting.html>

I ran both your script and the final script from the article and had no problems. Here is my output from your program:
--------
myScript.executing:
tell application "Finder"
get the name of every item in the desktop
end tell

Elapsed time = 0.164 seconds
Starting list of items on the desktop:
Curly
Unreal Tournament 2004 for MacOS X
AppleScriptTest.class
AppleScriptTest.java
testas.class
testas.java
--------

I get similar output every time I run your program.

What happens when you run this script from Script Editor:
--------
tell application "Finder"
get the name of every item in the desktop
end tell
--------

How long does the script take to execute from Script Editor?

- Ken

On May 14, 2004, at 12:41 PM, Seth Tager wrote:

Hmm. Interesting thought. The problem here is definitely with Applescript, though you're right that it may have to do with the java interface to applescript so I'll go ahead and post it there too.

Thanks,
Seth

--On Thursday, May 13, 2004 3:08 PM -0400 Graff <email@hidden> wrote:

You have the wrong list. This list is for AppleScript, not Java. You
probably want to post this on the Java-dev list:
<http://www.lists.apple.com/mailman/listinfo/java-dev>

- Ken

On May 11, 2004, at 4:33 PM, Seth Tager wrote:

I recently upgraded to panther and some scripts I ran in the past
using java now hang or take an unusually long time (20 min?) to run.

In attempting to debug, I've figured out that the scripts seem to be
waiting for (2 * timeout) seconds before returning control to java.

Interestingly enough, the script included below runs fast the very
first time I run it after restarting my machine, but after that it
always takes 2 minutes to run. (default applescript timeout is 1
minute) If I wrap the script in 'with timeout of 5 seconds ... end'
then the script will finish in just over 10 seconds.

The main script I'm trying to run involves Filemaker and I think it
hangs completely, but it's possible that it's waiting 2 minutes many,
many, times and so I never see it finish. (I've waited over 1/2 hour).

Any idea of what could be the problem? I'm running os 10.3.3

Seth


import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.NSApplication;
public class testas
{
public static void main(String[] args)
{

String script = "tell application \"Finder\" \n"
+ " get the name of every item "
+ " in the desktop \n"
+ "end tell\n";

NSApplication.sharedApplication();

// This creates a new NSAppleScript object
// to execute the script
NSAppleScript myScript =
new NSAppleScript(script);

// This dictionary holds any errors
// that are encountered during script execution
NSMutableDictionary errors =
new NSMutableDictionary();

// Execute the script!
System.out.println("myScript.executing:");
System.out.println(script);
long start = System.currentTimeMillis();
NSAppleEventDescriptor results =
myScript.execute(errors);
System.out.println("Elapsed time = " +
(System.currentTimeMillis()-start)/1000.0 + " seconds");

// Print out everything on your desktop
System.out.println("Starting list of items "
+ "on the desktop: ");

int numberOfDesktopItems = results.numberOfItems();
for(int i = 1; i <= numberOfDesktopItems; i++)
{
NSAppleEventDescriptor subDescriptor =
results.descriptorAtIndex(i);
System.out.println(" " +
subDescriptor.stringValue());
}

}
}
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: panther weirdness
      • From: Seth Tager <email@hidden>
References: 
 >panther weirdness (From: Seth Tager <email@hidden>)
 >Re: panther weirdness (From: Graff <email@hidden>)
 >Re: panther weirdness (From: Seth Tager <email@hidden>)

  • Prev by Date: Re: variable to shell script
  • Next by Date: Re: Keychain scripting... extract names from list
  • Previous by thread: Re: panther weirdness
  • Next by thread: Re: panther weirdness
  • Index(es):
    • Date
    • Thread