Re: Another shell/GUI cooperation script

2003-06-25 Thread Ken Williams
On Wednesday, March 26, 2003, at 02:17  PM, Ken Williams wrote:

Hey,

I've saved the following script as ~/bin/attach .  It lets me create a  
new Mail message from the command line with a given file as an  
attachment.  For example:

 % attach foo/bar/baz.doc
I was talking offline (well, online but not on *this* line =) with  
Chris Nandor, and he gave me some hints on how to find a solution for a  
problem I'd been having.  Whenever I executed applescript calls, I got  
the error:

## Component Manager: attempting to find symbols in a component alias  
of type (regR/carP/x!bt)

This even happened with 'osascript -e 1' at the command line, so it  
wasn't a perl-related problem, as it turned out.  The solution is here:

  http://www.macosxhints.com/article.php?story=20021211054158940

I moved /Library/QuickTime/Toast\ Video\ CD\ Support.qtx to /tmp/ and  
the error message went away.  Dunno if I'll miss it, but I rarely use  
Toast anymore and I certainly don't make video CDs.

(The original thread for this message is here:
http://groups.google.com/groups?hl=enlr=ie=UTF- 
8th=733e513bace2274arnum=1 )

 -Ken



Re: Another shell/GUI cooperation script

2003-03-27 Thread Chris Nandor
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Ken Williams) wrote:

 Chris, would it be fun/possible to convert all that applescript to perl?

Yep.  Note that currently you cannot tell an object in Mac::Glue, but no 
big deal; that is just syntactic sugar.  You'll see that apart from that, it 
is basically a line-by-line translation of syntax, using the same words but 
in Perl.

   use Mac::Glue ':all';

   my $mail = new Mac::Glue 'Mail';

   my $msg = $mail-make( new = 'outgoing message' );
   $mail-set( $mail-prop( visible = $msg ), to = gTrue() );

   my $last_char = $mail-obj( character = gLast(), of = content = $msg );
   $mail-make(
   new = 'attachment',
   at  = location( after = $last_char ),
   with_properties = {
   file_name = /etc/motd
   }
   );

   $mail-activate;

The most difficult thing is to know what it means, for example, to tell 
newMessage to set visible to true.  In this case, it means the same as set 
visible of newMessage to true, where visible is a property, so we 
prop(visible = $msg), to = gTrue().  Yay fun.

See similar fun with the location insertion record for after last character 
of content of message (the extra of in the perl is because content is a 
property and not an object ... at some point I want to get rid of that extra 
verbiage, which should be possible).

See the Mac::Glue POD for more details.

Of course, this currently works only in MacPerl (but the script above does, 
in fact, work from MacPerl in Classic to control Mail.app).  But as noted 
before, I am working to finish porting it all to work under Mac OS X, and 
most of the pieces are in place, I just need to find the time to finish it 
all up.  Before summer.  :)

-- 
Chris Nandor  [EMAIL PROTECTED]http://pudge.net/
Open Source Development Network[EMAIL PROTECTED] http://osdn.com/


Re: Another shell/GUI cooperation script

2003-03-26 Thread Ken Williams
On Wednesday, March 26, 2003, at 03:00  PM, Bruce Carter wrote:

Greetings Ken,

From a Perl newbie, and someone who just joined ths list, how does one 
learn about embedding AppleScript in Perl scripts?  Thanks very much 
for any pointers.
You can start by looking at
  http://search.cpan.org/author/DSUGAL/Mac-AppleScript/AppleScript.pm
That's the module I used in the example I posted to the list.

 -Ken