At 9:30 am +0100 15/03/01, Bart Lateur wrote:
>As for your problem: Perl has good access to the toolbox, so I think it
>must be feasable to make MacPerl get the data directly from the
>clipboard, without aid of Applescript? Anybody?
You may be able to get what you want from LMGetScrapHandle:
use Mac::LowMem;
my $lmh = LMGetScrapHandle;
my $str = $lmh->get;
If the clipboard contains text, $str seems to generally to contain
the characters 'TEXT' followed by a 'long' (four byte) number
representing the length of the subsequent string.
Depending on the application using the clipboard, a 'styl' group may
be prepended or appended to the 'TEXT' group. If present, this group
starts with the four characters 'styl' followed by any number of
characters containing the style information.
Further information can be got from LMGetScrapCount and LMGetScrapSize.
However not all applications do the same thing. Microsoft 'Word' for
example deposits a huge volume of stuff the structure of which is a
total mystery.
Mostly therefore, but not invariably, the clipboard string can be
captured by looking for the characters 'TEXT', evaluating the
following 'long' number and then extracting that subsequent number of
characters.
No doubt all this and more is set out somewhere in IM but I am afraid
I don't know which part.
HTH,
Alan Fry