applescript and java

Discussion in 'Java' started by logiclips@yahoo.com, Jan 9, 2006.

  1. Guest

    Hi,


    I want to call an applescript from Java. This works fine for some
    scripts. But the following script doesn't work:


    String script =
    "tell application \"System Events\" \n"
    + "do shell script \"/System/Library/CoreServices/Menu\\
    Extras/User.menu/Contents/Resources/CGSession -switchToUserID 1000 \"
    \n"
    + "delay 2 \n"
    //+ "keystroke \"" + pw + "\""
    + "keystroke \"password\" \n"
    + "delay 1 \n"
    + "keystroke return \n"
    + "end tell";


    ....with the following error:


    NSAppleScriptErrorBriefMessage = "Expected \U201c\"\U201d but found
    unknown token.";
    NSAppleScriptErrorMessage = "Expected \U201c\"\U201d but found
    unknown token.";
    NSAppleScriptErrorNumber = -2741;
    NSAppleScriptErrorRange = <00000055 00000001 >;


    Does anyone know why?


    Thanks a lot.
     
    , Jan 9, 2006
    #1
    1. Advertising

  2. Guest

    I also tried to call the shell script as Runtime process.

    But in this case the compiler says:
    "java.io.IOException: /System.Library/CoreServices/Menu: not found"
    So I guess he has a problem with the whitespace.

    Any solutions?

    Thanks a lot,

    Peter
     
    , Jan 9, 2006
    #2
    1. Advertising

  3. In article <>,
    wrote:

    > Hi,
    >
    >
    > I want to call an applescript from Java. This works fine for some
    > scripts. But the following script doesn't work:
    >
    >
    > String script =
    > "tell application \"System Events\" \n"
    > + "do shell script \"/System/Library/CoreServices/Menu\\
    > Extras/User.menu/Contents/Resources/CGSession -switchToUserID 1000 \"
    > \n"
    > + "delay 2 \n"
    > //+ "keystroke \"" + pw + "\""
    > + "keystroke \"password\" \n"
    > + "delay 1 \n"
    > + "keystroke return \n"
    > + "end tell";
    >
    >
    > ...with the following error:
    >
    >
    > NSAppleScriptErrorBriefMessage = "Expected \U201c\"\U201d but found
    > unknown token.";
    > NSAppleScriptErrorMessage = "Expected \U201c\"\U201d but found
    > unknown token.";
    > NSAppleScriptErrorNumber = -2741;
    > NSAppleScriptErrorRange = <00000055 00000001 >;
    >
    >
    > Does anyone know why?
    >
    >
    > Thanks a lot.


    I haven't done much at all with AppleScript, and none at all from within
    Java. But I seem to recall that AppleScript requires a special
    character to indicate continuation lines. Any chance that your "\n"
    entries are failing to provide that?

    = Steve =
    --
    Steve W. Jackson
    Montgomery, Alabama
     
    Steve W. Jackson, Jan 9, 2006
    #3
  4. Guest

    I don't think that this is the problem. It is also documented that one
    has to use \n entries.

    Peter
     
    , Jan 9, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon Fogh
    Replies:
    3
    Views:
    1,192
    matt neuburg
    Apr 25, 2005
  2. Replies:
    3
    Views:
    332
  3. Guest

    applescript/python question

    Guest, Aug 2, 2008, in forum: Python
    Replies:
    2
    Views:
    594
    Diez B. Roggisch
    Aug 2, 2008
  4. Replies:
    2
    Views:
    1,886
    Juanre
    Dec 16, 2009
  5. Phrogz
    Replies:
    3
    Views:
    138
    Phrogz
    Sep 7, 2006
Loading...

Share This Page