Go Back   The macosxhints Forums > OS X Help Requests > Applications



Reply
 
Thread Tools Rate Thread Display Modes
Old 12-30-2007, 08:39 AM   #1
DouglasMcKibbin
Prospect
 
Join Date: Nov 2007
Posts: 15
Show Page Setup dialog in Applescript

How does one force a page setup dialog in Applescript assuming the active application is Finder? What about in BBedit. What I really want to do is print a document in landscape mode with a 75% reduction in size. I cannot find the proper syntax in the dictionary.


tell application "finder"
print document
end tell


Thanks for any help
Douglas McKibbin
DouglasMcKibbin is offline   Reply With Quote
Old 12-30-2007, 09:26 AM   #2
tw
Hall of Famer
 
Join Date: Apr 2007
Posts: 3,342
the finder is not a document-based app (it's meant to work with files and folders), and so it doesn't have many sophisticated printing features on its own. the way to do this is to open the file in an application that is designed to handle documents, and script that. what kind of file is this, and why are you wanting to print it from the Finder?
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW-
tw is offline   Reply With Quote
Old 12-30-2007, 09:33 AM   #3
DouglasMcKibbin
Prospect
 
Join Date: Nov 2007
Posts: 15
Thanks,
This is a text file. I can use BBedit to add properties to the print command but I still cannot get the syntax right to either display the page setup or print dialogs even in BBedit. Ideally I would just like to print the document in landscape mode from BBedit and not have to choose landscape mode from the page setup dialog.
DouglasMcKibbin is offline   Reply With Quote
Old 12-30-2007, 10:41 AM   #4
cwtnospam
League Commissioner
 
Join Date: Jan 2005
Posts: 8,363
This will get you started...

I haven't figured out how to click the orientation.

Code:
tell application "TextEdit"
	activate
	tell application "System Events" to tell process "TextEdit"
		keystroke "p" using {command down, shift down}
		delay 0.2
		keystroke "75"

	end tell
end tell
cwtnospam is online now   Reply With Quote
Old 12-31-2007, 07:15 PM   #5
cwtnospam
League Commissioner
 
Join Date: Jan 2005
Posts: 8,363
This seems to work:

GUI scripting is no fun because it's easy to get ahead of the application, but I think I've got enough delays to avoid problems.
Code:
tell application "TextEdit"
	activate
	tell application "System Events" to tell process "TextEdit"
		keystroke "p" using {command down, shift down}
		delay 0.5
		keystroke "075"
		delay 0.5
		keystroke tab
		keystroke tab
		keystroke tab
		key code 124 -- right arrow to landscape 1st option
		key code 124 -- right arrow to landscape 2nd option
	end tell
end tell
cwtnospam is online now   Reply With Quote
Old 01-01-2008, 04:31 PM   #6
DouglasMcKibbin
Prospect
 
Join Date: Nov 2007
Posts: 15
thanks. The following script works for Page Setup and Print....


tell application "TextEdit"
activate
open {file (filepath)}
tell application "System Events" to tell process "TextEdit"
keystroke "p" using {command down, shift down}
delay 1
keystroke "075"
delay 1
keystroke tab
keystroke tab
keystroke tab
key code 124 -- right arrow to landscape 1st option
key code 124 -- right arrow to landscape 2nd option
key code 36
delay 1
keystroke "p" using {command down}
delay 2
key code 36
delay 4
keystroke "w" using {command down}
end tell
quit
end tell
DouglasMcKibbin is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:06 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Site design © Mac Publishing LLC; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of Mac Publishing LLC.