[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] floating point params with Mac::AppleEvents::Simple



I'm trying to script Photoshop with MacPerl, via Mac::AppleEvents::Simple. (I'm using the PhotoScripter plug-in to make Photoshop scriptable).

I need to send parameters which are 'doub' and 'long' types.

Here is what I tried:

# apply Photoshop unsharp masking filter
# usage: applyPSusm($dobj, $radius, $amount, $threshold);
sub applyPSusm {
# get the parameters
my ($dobj, $radius, $amount, $threshold) = @_;
# build the parameter string
my $param = "'----':$dobj, " .
"'^Typ':type(fUnM), prdt:{Rds :doub(@\), Amnt:long(\@), Thsh:long(\@)}";
# send the Apple Event
do_event(qw/Indy kFlt 8BIM/, $param, $radius, $amount, $threshold);
}

This almost works, but puts wacky values in the AppleEvent (when viewed with CaptureAE).

For example, with $radius=2, $amount=100, $threshold=10, here is the AppleEvent:

Process("Adobe® Photoshop® 5.5").SendAE "Indy,kFlt,'----':obj {want:type(docu), from:'null'(), form:ID , seld:1045}, '^Typ':type(fUnM), prdt:{Rds :0, Amnt:3, Thsh:46922336}}4"

The following works fine when the parameters are integer values:

# apply Photoshop unsharp masking filter
# usage: applyPSusm($dobj, $radius, $amount, $threshold);
sub applyPSusm {
# get the parameters
my ($dobj, $radius, $amount, $threshold) = @_;
# build the parameter string
my $param = "'----':$dobj, " .
"'^Typ':type(fUnM), prdt:{Rds :$radius, Amnt:$amount, Thsh:$threshold}";
# send the Apple Event
do_event(qw/Indy kFlt 8BIM/, $param);
}

However, I need $radius to be floating point, which causes the above routine to fail.

Any suggestions on how to do this properly?

-Bill

----------
William B. Birkett
Precision Color, Inc.
9200 General Drive
Plymouth, MI 48170 (USA)

Phone: (734) 459-5640 Direct: (734) 414-3608
Cell: (734) 516-4790 FAX: (734) 459-4210