Re: Entering scripts in raw format
Re: Entering scripts in raw format
- Subject: Re: Entering scripts in raw format
- From: has <email@hidden>
- Date: Thu, 4 Jan 2007 21:56:54 +0000
Jon Pugh wrote:
At 5:56 PM +0000 1/4/07, Rolf Howarth wrote:
Well, the events ARE documented - in a header file - and I guess I
can write some native code to receive them. For example, the
relevant portion is
@result kXMLDataKey The XML data, represented as a UTF-8 string
(typeUTF8Text)
...
#define kXMLDataKey 'xmlD'
I'd prefer not use C++ for this if I can help it though. It's
frustrating that I can get most of the way there with AppleScript,
just not read the result!
Bad news. AppleScript can't retrieve any result except '----'.
...and keyErrorNumber/keyErrorString, of course.
Does sound like a particularly weird-n-wonky application
implementation though. Might be an idea for the OP to ask the
application developer to sort it out at their end.
You are stuck going to C/C++.
Or you could use Ruby or Python with aem/appscript, which is open-
source and very customisable (see sig for links). For example, the
following script defines custom AEM::Event and AEM::Application
subclasses that return all the parameters from a reply event in a
Hash, allowing clients to process those parameters as they like:
#######
#!/usr/local/bin/ruby
require 'aem'
# Normal usage examples:
a = Application.by_path('/Applications/TextEdit.app')
p a.event('coregetd', {'----' => AEM.app.property('pnam')}).send
# "TextEdit"
p a.event('SomeEvnt').send
# Application could not handle this command. (Send::CommandError)
# Define custom AEM::Application subclass for use with problem
application:
class RawEvent < Send::Event
def send(timeout=KAE::KAEDefaultTimeout,
flags=KAE::KAECanSwitchLayer + KAE::KAEWaitReply)
# Returns all of a reply event's parameters in a Hash, instead of
# extracting keyAEResult/keyErrorNumber and returning/raising that.
begin
reply_event = _send_apple_event(flags, timeout)
rescue AE::MacOSError => err # The Apple Event Manager raised an
error.
if not (@_event_code == 'aevtquit' and err.to_i == -609) # Ignore
invalid connection errors (-609) when quitting
raise Send::CommandError.new(err.to_i, nil, err)
end
else
@_codecs.unpack(reply_event.coerce(KAE::TypeAERecord))
end
end
end
class RawApplication < AEM::Application
Event = RawEvent
end
# Custom usage examples:
a = RawApplication.by_path('/Applications/TextEdit.app')
p a.event('coregetd', {'----' => AEM.app.property('pnam')}).send
# {AEM::AEType.new("----")=>"TextEdit"}
p a.event('SomeEvnt').send
# {AEM::AEType.new("errn")=>-1708}
#######
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden