In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Vince) wrote: > Some dude working in my company needs a program that does this- > > - There are over a 100 PDF files in some folder on a Mac Machine > - The program to be written is supposed to invoke Adobe Acrobat > Professional 7 (Mac version) and open each file from the directory > - Once each file is opened in Acrobat 7, it is supposed to push Alt + E > (or similar) and then 'n' (or similar) in order to enable commenting on the > PDF file. > - The program is then supposed to push Alt +F and then 'S' to save the > file > - This is to happen for all the files in that folder. > > Someone supposedly told the dude that this script in Perl was easy to write!
This is likely fairly simple to do in Perl, with Mac::Glue, as long as the app is "scriptable" and as long as it can do what you want to do via Apple events, and as long as you can figure out HOW to do those things. You can use AppleScript too, but I find Mac::Glue to be much easier to use, once you get the hang of it, since you can handle your logic flow and filesystem accesses much easier in Perl. Note that AppleScript will not be able to do something (in general) that Mac::Glue cannot do. If you're running Tiger with the default Perl, you already have Mac::Glue installed, though you may wish to update it. If yes to Toger and no to updating Mac::Glue, you will need to run this first: cd /System/Library/Perl/Extras/bin/ sudo ./gluedialect sudo ./gluescriptadds sudo ./gluemac '/System/Library/CoreServices/System Events.app' sudo ./gluemac /System/Library/CoreServices/Finder.app And then the line above becomes something like: sudo ./gluemac /Applications/Acrobat\ Professional Else, after installing/updating Mac::Glue, just do: sudo gluemac /Applications/Acrobat\ Professional As I don't have the app in question, I can only guess how to do what you ask; it's different for every app. So below I give some guesses. I see the 6.0 dictionary here: http://macscripter.net/app_dictionaries/dictionary.php?id=196_0_1_0_C It has no real clues; you might need to get into UI scripting, which is far more of a pain. You can tell the UI to hit a key combination, or select a menu, type a letter, and so on. The below assumes you won't need to do that. use File::Spec::Functions; use Mac::Glue ':all'; my $dir = '/Users/pudge/Desktop/PDFs'; # using Safari for testing ... it opens each PDF, and closes it my $acrobat = new Mac::Glue 'Safari'; #'Acrobat Professional'; # etc. $acrobat->activate; opendir my $dh, $dir or die "Can't open $dir: $!"; chdir $dir or die "Can't chdir $dir: $!"; for my $file (readdir $dh) { # or whatever ... next unless $file =~ /\.pdf$/i && -f $file; my $pdf = $acrobat->open($file); ## ideally, $pdf will contain a reference to the just-opened ## document, but not for every app, so as a backup: $pdf ||= $acrobat->obj(window => 1); # get front window ## the above could also properly be: # $pdf ||= $acrobat->obj(document => 1, window => 1); ## no idea how to do this part; see "gluedoc $appname" on the ## command line for docs for the app, here's a wild guess; ## if someone could show me the AppleScript dictionary for the ## app, I could take a look; this is the part that may need to ## be done with UI scripting # $pdf->prop('commenting')->set(to => 1); ## usually, you can close "with saving," but you may ## need to save explicitly, or you vice versa (again, ## app-dependent); the combined close "with saving" ## is the most efficient method # $pdf->save; $pdf->close(saving => enum('yes')); } -- Chris Nandor [EMAIL PROTECTED] http://pudge.net/ Open Source Technology Group [EMAIL PROTECTED] http://ostg.com/
