Friday, December 19, 2014

#1 2007-01-02 12:01:31 pm

mcgrailm
Member
Registered: 2006-11-24
Posts: 514

Scripting Preview

does anyone out there know if there is a way to give preview commands without driving the GUI like a service or can will it accept a command line ?

Offline

 

#2 2007-01-02 12:14:12 pm

StefanK
Member
From: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 10734
Website

Re: Scripting Preview

Hi,

Preview.app is (a bit) scriptable, but you must enable it manually.
Open the Terminal and type (better copy wink ) this:

Code:

defaults write /Applications/Preview.app/Contents/Info NSAppleScriptEnabled -bool YES


regards

Stefan

Offline

 

#3 2007-01-02 12:22:32 pm

mcgrailm
Member
Registered: 2006-11-24
Posts: 514

Re: Scripting Preview

ok I ran that but I got back some stuff I've never seen before..... I take it this makes it so I can give it a command from terminal  ?

Offline

 

#4 2007-01-02 12:22:45 pm

Bruce Phillips
Administrator
Registered: 2004-07-15
Posts: 2649

Re: Scripting Preview

See also: Minimal Scriptability

Edit: mcgrailm, it turns on some very basic AppleScript support.

Offline

 

#5 2007-01-02 12:35:27 pm

mcgrailm
Member
Registered: 2006-11-24
Posts: 514

Re: Scripting Preview

hmm  in either case I am unable to set that value to true as it doesn't seem to exist for that app

what I'm really trying to do is get preview to convert a PS to PDF as pstopdf makes a much llarger file than if I save the PS to PDF from Preview

what about through Xcode is there some way I can get that same result there ?

Offline

 

#6 2007-01-02 12:40:45 pm

Bruce Phillips
Administrator
Registered: 2004-07-15
Posts: 2649

Re: Scripting Preview

mcgrailm wrote:

ok I ran that but I got back some stuff I've never seen before

I don't get any output from that command; Maybe we can help if you post that "stuff."

Offline

 

#7 2007-01-02 12:48:34 pm

StefanK
Member
From: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 10734
Website

Re: Scripting Preview

mcgrailm wrote:

ok I ran that but I got back some stuff I've never seen before..... ?

Do you use Panther?
Then try the boolean value 1 instead of YES


regards

Stefan

Offline

 

#8 2007-01-02 12:49:14 pm

mcgrailm
Member
Registered: 2006-11-24
Posts: 514

Re: Scripting Preview

here it is

McGrail:~ mcgrail$ defaults write/Applications/Preview.app/Contents/Info NSAppleScripterEnabled -bool YES
Command line interface to a user's defaults.
Syntax:

'defaults' [-currentHost | -host <hostname>] followed by one of the following:

  read                                 shows all defaults
  read <domain>                        shows defaults for given domain
  read <domain> <key>                  shows defaults for given domain, key

  read-type <domain> <key>             shows the type for the given domain, key

  write <domain> <domain_rep>          writes domain (overwrites existing)
  write <domain> <key> <value>         writes key for domain

  rename <domain> <old_key> <new_key>  renames old_key to new_key

  delete <domain>                      deletes domain
  delete <domain> <key>                deletes key in domain

  domains                              lists all domains
  find <word>                          lists all entries containing word
  help                                 print this help

<domain> is ( <domain_name> | -app <application_name> | -globalDomain )
         or a path to a file omitting the '.plist' extension

<value> is one of:
  <value_rep>
  -string <string_value>
  -data <hex_digits>
  -int[eger] <integer_value>
  -float  <floating-point_value>
  -bool[ean] (true | false | yes | no)
  -date <date_rep>
  -array <value1> <value2> ...
  -array-add <value1> <value2> ...
  -dict <key1> <value1> <key2> <value2> ...
  -dict-add <key1> <value1> ...

Offline

 

#9 2007-01-02 12:51:00 pm

Bruce Phillips
Administrator
Registered: 2004-07-15
Posts: 2649

Re: Scripting Preview

I think you're missing a space after "write." smile

Offline

 

#10 2007-01-02 12:53:08 pm

mcgrailm
Member
Registered: 2006-11-24
Posts: 514

Re: Scripting Preview

I opened the info.plist and its not there

Offline

 

#11 2007-01-02 12:54:53 pm

Bruce Phillips
Administrator
Registered: 2004-07-15
Posts: 2649

Re: Scripting Preview

Can you add it yourself?

Offline

 

#12 2007-01-02 01:00:24 pm

mcgrailm
Member
Registered: 2006-11-24
Posts: 514

Re: Scripting Preview

no I don't have permission

Offline

 

#13 2007-01-02 01:08:36 pm

Bruce Phillips
Administrator
Registered: 2004-07-15
Posts: 2649

Re: Scripting Preview

I thought that would be the case. Unless you can use sudo, you'll have to find a different way to do what you want.

Side note: You typed "Scripter" instead of "Script"

Offline

 

#14 2007-01-02 01:16:55 pm

mcgrailm
Member
Registered: 2006-11-24
Posts: 514

Re: Scripting Preview

Ok thank you all for your help ......

Offline

 

#15 2007-01-02 01:21:11 pm

StefanK
Member
From: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 10734
Website

Re: Scripting Preview

I knew, why I wrote

StefanK wrote:

(better copy wink )

tongue
smile


regards

Stefan

Offline

 

#16 2011-08-04 07:49:30 pm

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Scripting Preview

In 10.7 Info.plists are owned by root:

Code:

sudo defaults write /Applications/Preview.app/Contents/Info NSAppleScriptEnabled -bool true
sudo chmod 644 /Applications/Preview.app/Contents/Info.plist
sudo codesign -f -s - /Applications/Preview.app

Now tell app "Preview" to windows shouldn't cause an error. As in 10.6, Preview still won't have a dictionary.

Last edited by l-ri (2011-08-04 07:50:28 pm)


One mans trash is another mans treasure

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.025 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)