Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

applescript and java

Thread view: 
logiclips@yahoo.com - 09 Jan 2006 17:29 GMT
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.
logiclips@yahoo.com - 09 Jan 2006 17:35 GMT
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
Steve W. Jackson - 09 Jan 2006 20:02 GMT
> Hi,
>
[quoted text clipped - 25 lines]
>
> 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 =
Signature

Steve W. Jackson
Montgomery, Alabama

logiclips@yahoo.com - 09 Jan 2006 23:28 GMT
I don't think that this is the problem. It is also documented that one
has to use \n entries.

Peter


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.