Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

Article:
  Controlling Your Mac with AppleScript and Java
Subject:   Panther problems
Date:   2003-12-15 04:38:33
From:   anonymous2
I just updated to Panther and now I have the problem, that the AppleScripts I execute from Java take one minute to run. Before I took not even a second.
Scripts like "get 'hello'" will execute very fast, but if I have to add an "tell application ..." statement, it takes minutes until the result is returned.
Does anyone have an idea, what the problem is?


thanx
chaos

Full Threads Oldest First

Showing messages 1 through 5 of 5.

  • Panther problems
    2004-05-11 22:08:36  jtangney [View]

    Yup. Me too.

    I have a completely clean Panther install, and the example app takes around a minute or more to run. I put some debugging code in there, as well as a compile call, but nothing speeds it up. The execute is what takes forever.

    I was hoping that Java + AS woule be useful, but this is completely unusable. Very disappointing. :-(

    --johnt
  • Panther problems
    2004-03-16 08:04:54  st0g1e [View]

    has anybody found a solution to this???
  • Panther problems
    2003-12-17 13:22:04  sdwr98 [View]

    I'm not seeing this problem... I did an Archive and Install of Panther, then got all the latest software updates.

    Which example are you trying to run?
    • Panther problems
      2004-01-18 18:11:53  coderanger [View]

      I am seeing the same thing. I even modified your code to compile a text script and execute it. A simple finder directory item list takes over 2 minutes real time when I execute using "time" to measure it. I an runnign on a pristin 12" powebook that same with Panther installed. I am going to try doing and exec of 'osascript' to see if that is better.

      Here is my code (modified from yours). It takes one command-line arg--a text fiel that is an Applescript.

      public class RunScript
      {
      public static void main(String[] args)
      {
      // shared NSApplication
      NSApplication.sharedApplication();

      // read in script file
      String scriptText = "";
      try {
      BufferedReader inStream = new BufferedReader(new FileReader(args[0]));
      String inputLine;

      while ((inputLine = inStream.readLine()) != null) {
      scriptText += inputLine + "\n";
      }
      } catch (IOException e) {
      System.out.println("IOException: " + e );
      System.exit(1);
      }


      // Script Object creation and execution
      NSAppleScript scriptObj = new NSAppleScript(scriptText);
      // dict for script exec errors
      NSMutableDictionary errorInfo = new NSMutableDictionary();
      // compile
      boolean compileResult = scriptObj.compile(errorInfo);
      System.out.println("Compile status:" + compileResult);
      // execute
      System.out.println("Running script...");
      NSAppleEventDescriptor aeResult = scriptObj.execute(errorInfo);

      // status report
      System.out.println("Script results complete..");

      if (aeResult != null ) {
      int itemCount = aeResult.numberOfItems();
      System.out.println("Found " + itemCount + "items in aeResult.");

      // print results
      NSAppleEventDescriptor subDescriptor;

      for(int i = 1; i <= itemCount; i++)
      {
      subDescriptor =
      aeResult.descriptorAtIndex(i);
      System.out.println(" " + subDescriptor.stringValue());
      }
      }
      else {
      System.out.println("aeResult was null.");
      }
      // status
      System.out.println("Script run complete."); }
      }

      • Panther problems
        2004-04-14 18:01:03  TToolsSeth [View]

        I'm having the same experience. A script that used to work now takes a really long time. I've discovered that it's related to timeout and that the script will return in 2 * timeout seconds (default timeout is 1 minute, which is why you see the 2 minute duration). If you wrap your script in "with timeout of 10 seconds ... end" it will only take 20 seconds to execute.

        Is there any forum for reporting bugs with the Applescript glue code?