Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > applescript and java

Reply
Thread Tools

applescript and java

 
 
logiclips@yahoo.com
Guest
Posts: n/a
 
      01-09-2006
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.

 
Reply With Quote
 
 
 
 
logiclips@yahoo.com
Guest
Posts: n/a
 
      01-09-2006
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

 
Reply With Quote
 
 
 
 
Steve W. Jackson
Guest
Posts: n/a
 
      01-09-2006
In article < .com>,
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
 
Reply With Quote
 
logiclips@yahoo.com
Guest
Posts: n/a
 
      01-09-2006
I don't think that this is the problem. It is also documented that one
has to use \n entries.

Peter

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting 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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python tricks with applescript in OS-X joanmg@gmail.com Python 2 12-16-2009 05:28 PM
applescript/python question Python 2 08-02-2008 03:26 PM
Calling Mac programs from Python instead of from AppleScript dvschorre@sbcglobal.net Python 3 03-20-2008 12:08 PM
Ruby OSA "AppleScript" for the Macintosh Phrogz Ruby 3 09-07-2006 08:26 PM
Calling an applescript with parameters Jon Fogh Java 3 04-25-2005 04:21 PM



Advertisments