• 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: Fetching result from NSAppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fetching result from NSAppleScript


  • Subject: Re: Fetching result from NSAppleScript
  • From: has <email@hidden>
  • Date: Fri, 20 Jul 2007 01:32:45 +0100

On 20 Jul 2007, at 00:37, Nirnimesh wrote:

Again, if you want more specific advice you'll need to say more about
what it is you're working on.

I'm infact working with python already. I want to be able to execute an applescript like:


activate application "Safari"
tell application "System Events"
tell process "Safari"
-- check a link
get name of UI element "Îñţérñåţîöñåļîžåţîöñ" of group 4 of UI element 1 of scroll area 1 of group 2 of front window
end tell
end tell


I expect the above script to return: Îñţérñåţîöñåļîžåţîöñ to my python script.

I couldn't get this to work with "osascript -e" system() call with python. I hunted around and discovered that osascript and the shell will mess up with the non-ascii characters above.

That's not osascript's fault, it's AppleScript's. For starters, you're using characters in your AppleScript source code that aren't in your system's primary encoding, so it won't compile correctly. You can work around that problem by using the string's raw representation in your script:


	«data utxt EB9674FC8E72968C74FC949A968C6CFC947AFF8C74FC949A96»

or you could pass the string to the script as a parameter to the run handler.

However, AppleScript still won't be able to provide a correct textual representation of the returned string, so if you want to display arbitrary results correctly the only way you can do that is by unpacking the descriptor returned by -executeAndReturnError: and formatting the results yourself (a non-trivial task).

Anyway, since you're working in Python couldn't you use Python appscript? Like I say, AppleScript is definitely wanting when it comes to doing anything Unicode-related. So unless you're trying to implement attachability in your application (c.f. folder actions, Mail rules) there probably isn't any reason why you have to use AppleScript, and you'll save yourself a bunch of Unicode-related headaches if you can avoid it.

HTH

has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
http://appscript.sourceforge.net/objc-appscript.html

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Fetching result from NSAppleScript (From: has <email@hidden>)
 >Re: Fetching result from NSAppleScript (From: Nirnimesh <email@hidden>)
 >Re: Fetching result from NSAppleScript (From: has <email@hidden>)
 >Re: Fetching result from NSAppleScript (From: Nirnimesh <email@hidden>)

  • Prev by Date: Re: Finder Open file versus double-clicking file
  • Next by Date: Re: Separator in the case of an NSOutlineView
  • Previous by thread: Re: Fetching result from NSAppleScript
  • Next by thread: Re: Fetching result from NSAppleScript
  • Index(es):
    • Date
    • Thread