Recent Posts

Pages: [1] 2 3 4 5 ... 10
1
Hi there! I don't use ID hence I don't script ID, but can't address either spread or page? If so, you could target say the last page of spread 2, or page 2 of spread 17. Does this make sense? Another possible way (to me) would be to add the width of the page to the measures so that the new object to be created falls on the right hand page. Are you with me? Then you'd need to test the page number and detect wether you're on a odd or even page. HTH.
2
Adobe InDesign scripting / Text Frames for Page 2 to End Up on Page 1
« Last post by mbornbach on June 12, 2017, 05:28:44 PM »
I have a script that measures text frames and places those measurements as text inside the text frame. The only problem I'm having is that InDesign wants to put the measurements for page 2 of the spread on page 1. What do I need to change to convince InDesign to put the measurements for page 2 on page 2?

Code: [Select]

--------------------------------------------------------------------------------------------------------------
--CREATING SEPARATE NEW LAYER FOR THE MEASURMENTS AND TEXT BOXES IF IT DOESN'T EXIST
--------------------------------------------------------------------------------------------------------------

open afile


tell document 1 -->Beginning of tell document 1 block
try
set measuringLayer to make layer with properties {name:"Measure"}

--Telling script to use existing measure layer if it already exists
on error
set measuringLayer to layer "Measure"
end try



--------------------------------------------------------------------------------------------------------------
--GETTING MEASUREMENTS AND ADDING THEM AS TEXT TO THE MEASURED TEXT FRAME
--------------------------------------------------------------------------------------------------------------

--Displaying a message to the user if there are no text frames on the measure layer
if (count of every text frame of measuringLayer) is 0 then -->Beginning of if statement
set boxesDontExist to true -->Using this to display a dialog further down in the script, after the repeat loop ends.


--Getting the measurements of every text frame on the measure layer
else

set my_pages to every page
repeat with a_page in my_pages
set page_name to get the name of a_page


set boxesExist to true -->Using this to display a dialog further down in the script, after the repeat loop ends.
set measuringTextFrames to (every text frame of page page_name whose item layer is measuringLayer)
repeat with measuringTextFrame in measuringTextFrames -->Beginning of second repeat loop


--Geometric bounds are {top side, left side, bottom side, right side}, also referred to as {y1, x1, y2, x2}
set y2 to item 3 of geometric bounds of measuringTextFrame -->y2 is the bottom side of the frame
set y1 to item 1 of geometric bounds of measuringTextFrame -->y1 is the top side of the frame
set x1 to item 2 of geometric bounds of measuringTextFrame -->x1 is the left side of the frame
set x2 to item 4 of geometric bounds of measuringTextFrame -->x2 is the right side of the frame


--Doing some math with those measurements to figure out the square inches of each frame
set frameHeight to y2 - y1 -->bottom of frame - top of frame = height of the frame
set frameWidth to x2 - x1 -->right side of frame - left side of frame = width of the frame
set frameSquareInchesLong to frameHeight * frameWidth -->multiplying height time width to get square inches
set frameSquareInches to my roundThis(frameSquareInchesLong, 2) -->making the number round to only 2 decimal points instead of a gazillion
set inchMarks to {"''"} -->Adding the inch marks in between quotes
set measurementText to frameSquareInches & inchMarks as string -->Final result followed by the inch marks (example: 3.08")


--Creating the text frames that will hold the measurements
tell page page_name to set displayTextFrame to make text frame with properties {layer:measuringLayer, geometric bounds:{(y1 + "0.05"), (x1 + "0.075"), y2, x2}, stroke color:"None", stroke weight:0}


--Inserting the square inches figured into each frame as text
tell displayTextFrame

--Adding the drop shadow to the text
apply object style using dropShadowStyle

--Adding the calculated result for square inches in each text frame
set contents of insertion point -1 to measurementText

end tell

end repeat -->End of second repeat loop





end repeat --> End of repeat with page loop
end if -->End of if statement
3
Quark XPress support / Re: lock picture box to text in quarkxpress 8.0
« Last post by VernonP on June 12, 2017, 06:04:25 AM »
lock picture box to text in quarkxpress 8.0

How do you do this?
4
Quark XPress scripting / Re: Removing Paragraph Breaks
« Last post by Jean-Marie Schwartz on March 27, 2017, 03:40:31 AM »
Hi! Have you tried to concatenate doc files via a shell script? (Or am I missing sth?)
This might be helpful too: https://forums.macrumors.com/threads/combine-word-documents-through-script.1907370/ (and maybe this one: https://groups.google.com/forum/#!topic/microsoft.public.mac.office.word/tviRk1gUL80 ?)
5
Quark XPress scripting / Removing Paragraph Breaks
« Last post by mbornbach on March 23, 2017, 02:04:46 PM »
I have this script that combines word files into one file. I then drop that Word file onto Quark and drag it off to the side.
The problem I'm having is that the imported text cuts off after the first paragraph and the rest of the text is overflowing.
I'm trying to figure out how to replace the paragraph break in the code with something that won't cut off in Quark; either by changing something in this script in Word or by making a second script that changes it in Quark.

Code: [Select]
 on open of droppedfiles
with timeout of 1500 seconds
tell application "Microsoft Word"
set new_document to make new document
repeat with afile in droppedfiles
set file_path to afile as string
set filename to name of afile
set paste_range to text object of new_document
set collapsed_range to collapse range paste_range direction collapse end
insert file file name file_path at collapsed_range
end repeat
end tell
end timeout
end open
6
Adobe Photoshop scripting / Re: Script works except for Photoshop CS5
« Last post by Jean-Marie Schwartz on March 02, 2017, 05:25:44 AM »
Hi!

Most of the time if a script crashes the app other people won't necessary test the code  :)
Then it would be helpful to be a bit more accurate: at what stage does it crash? What script editor do you use? You'd need to add some log reports along the code as to see what happens and when does the crash occurs.
Does this make sense?
7
Adobe Photoshop scripting / Script works except for Photoshop CS5
« Last post by mbornbach on February 21, 2017, 08:49:08 AM »
I've gotten the following script to work on Photoshop CS5.5, Photoshop CC 2014 and Photoshop CC 2017. It crashes with Photoshop CS5. Any ideas how to fix this would be greatly appreciated. Thanks!

Code: [Select]
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------

--HOW THIS SCRIPT WORKS:
--This applescript droplet runs whenever a file is dropped onto it.
--First, it creates a backup folder on the user's desktop called "Backups of Images"
--Then, it makes a backup copy to the user's desktop just in case the layered version is needed
--It opens each dropped file in photoshop where it is converted to CMYK
--It attempts to save and close the file
--It provides a bug fix for the overwriting save problem when using Photoshop CS5 or CS5.5 on newer operating systems
--It displays a dialog to the user if there were any problems
--It displays a success dialog to the user if everything went well

-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------


on open droppedfiles
   with timeout of 1500 seconds
       
       ---------------------------------------------------------------------------------------------------
       -- CREATING AN EMPTY LIST TO ADD PROBLEM FILES TO
       ---------------------------------------------------------------------------------------------------
       
       set problem_list to {}
       set layered_list to {}
       
       
       ---------------------------------------------------------------------------------------------------
       -- CREATING BACKUP FOLDER IF IT DOESN'T EXIST
       ---------------------------------------------------------------------------------------------------
       
       repeat with afile in droppedfiles
           
           --SETTING THE PATH TO THE DESKTOP
           tell application "Finder"
               set desktop_folder to path to desktop as string
           end tell
           
           
           --CREATING BACKUP FOLDER ON THE DESKTOP IF IT DOESN'T EXIST YET
           if not my CheckForFolder(desktop_folder & "Backups of Images:") then
               tell application "Finder"
                   set backup_folder to make new folder at folder desktop_folder with properties {name:"Backups of Images"}
               end tell
           end if
           set backup_folder to desktop_folder & "Backups of Images:" as string
           
           
           -------------------------------------------------------------------------------------
           --BACKING UP THE IMAGES BEFORE PROCESSING
           -------------------------------------------------------------------------------------
           
           tell application "Finder"
               set file_ext to name extension of afile
               set filename to name of afile
               duplicate afile to alias backup_folder with replacing
           end tell
           
           
           -------------------------------------------------------------------------------------
           --CHANGING THE COLOR MODE TO RGB IN PHOTOSHOP
           -------------------------------------------------------------------------------------
           
           tell application "Adobe Photoshop CC 2017"
               activate
               set display dialogs to never
               open afile showing dialogs never
               
               tell current document
                   
                   --Adding the image's filename to a warning list if the image has multiple layers
                   set layer_count to (count of layers) as string
                   if layer_count is greater than 1 then
                       set layered_list to layered_list & " " & filename & return
                       
                       
                       --Doing the rest of the processing if the image is flattened
                   else
                       
                       try
                           
                           --Changing color mode to CMYK
                           change mode to CMYK
                           
                           
                           -------------------------------------------------------------------------------------
                           --SAVING THE IMAGE
                           -------------------------------------------------------------------------------------
                           
                           --Trying to save
                           try
                               if file_ext contains "tif" or file_ext contains "jpg" or file_ext contains "jpeg" or file_ext contains "png" then
                                   save
                               else
                                   save in file file_path as TIFF appending lowercase extension without copying
                               end if
                               
                               
                               --This is the bug fix that saves a copy of the image
                               --Photoshop CS5.5 on newer operating systems throws an error when overwriting files on a server with an smb connection
                               --Apple says this is Adobe's fault. Adobe says this is Apple's fault.
                           on error
                               
                               --Trimming the extension of the filename so we can add _1, _2, _3 to the end of the filename
                               tell application "Finder"
                                   set old_delims to AppleScript's text item delimiters
                                   set AppleScript's text item delimiters to "." & file_ext
                                   set path_without_extension to first text item of file_path
                               end tell
                               
                               --Adding _1, _2, _3, etc. to the end of the filename to save a copy
                               repeat
                                   set the name_increment to 1
                                   set revised_file_path to path_without_extension & "_" & (name_increment as string) & "." & file_ext as string
                                   try
                                       if file_ext contains "tif" then
                                           save in file revised_file_path as TIFF appending lowercase extension without copying
                                       else if file_ext contains "jpg" or file_ext contains "jpeg" then
                                           save in file revised_file_path as JPEG appending lowercase extension without copying
                                       else if file_ext contains "png" then
                                           save in file revised_file_path as PNG appending lowercase extension without copying
                                       else
                                           save in file revised_file_path as TIFF appending lowercase extension without copying
                                       end if
                                       exit repeat
                                   on error
                                       set revised_file_path to path_without_extension & "_" & (name_increment as string) & "." & file_ext as string
                                       save in file revised_file_path
                                       
                                       
                                       --Using the finder to rename the file to the original name
                                       tell application "Finder"
                                           set revised_file to revised_file_path as alias
                                           try
                                               set name of revised_file to filename
                                           end try
                                       end tell
                                   end try
                                   
                               end repeat
                               
                               --Resetting applescript's text item delimiters
                               tell application "Finder" to set AppleScript's text item delimiters to old_delims
                               
                           end try
                           
                           
                           --Closing the document
                           close saving no
                           
                       on error
                           set problem_list to problem_list & " " & filename & return
                       end try
                   end if
               end tell
           end tell
       end repeat
       
       
       ---------------------------------------------------------------------------------------------------
       -- DISPLAYING AN ERROR OR SUCCESS DIALOG TO THE USER
       ---------------------------------------------------------------------------------------------------
       
       --Display error message if there were any problems
       if problem_list is not {} and layered_list is {} then
           tell application "SystemUIServer"
               display dialog "THERE WAS A PROBLEM WITH SOME IMAGES:" & return & "The following files had a problem and have been left open in Photoshop. Please try dropping them on the script again:" & return & return & problem_list & return & "Images not in the above list processed successfully. If needed, the originals are in a folder called 'Backups of Images' on your desktop." as string with icon caution giving up after 900
           end tell
           
           --Display error/layered message if there were any problems and there were layered images
       else if problem_list is not {} and layered_list is not {} then
           tell application "SystemUIServer"
               display dialog "ATTENTION:" & return & return & "THERE WAS A PROBLEM WITH SOME IMAGES:" & return & "The following files had a problem and have been left open in Photoshop. Please try dropping them on the script again:" & "--------------------" & return & return & problem_list & return & return & "IMAGES WERE LAYERED:" & return & "The color mode was not changed on the following layered images because changing the color mode of layered images can have unexpected effects:" & return & return & layered_list & return & return & "Images not in either of the lists were processed successfully. If needed, the originals are in a folder called 'Backups of Images' on your desktop." as string with icon stop giving up after 900
           end tell
           
           
           --Display layered message if there were layered images
       else if problem_list is {} and layered_list is not {} then
           tell application "SystemUIServer"
               display dialog "ATTENTION: IMAGES WERE LAYERED" & return & "The color mode was not changed on the following layered images because changing the color mode of layered images can have unexpected effects:" & return & return & layered_list & return & "Any images not in the above list processed successfully. If needed, the originals are in a folder called 'Backups of Images' on your desktop." with icon stop giving up after 900
           end tell
           
           --Display success message if everything is good
       else
           tell application "SystemUIServer"
               display dialog "SUCCESS!" & return & "All the files have been successfully converted to CMYK." & return & return & "If needed, the originals are in a folder called 'Backups of Images' on your desktop." with icon note giving up after 900 -->Will display the success message to the user for 15 minutes or until ok is clicked
           end tell
       end if
       
       
   end timeout
end open

---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------

--FUNCTION TO CHECK IF A FOLDER EXISTS
on CheckForFolder(thisFolder)
   tell application "Finder"
       return (exists folder thisFolder)
   end tell
end CheckForFolder
8
Quark XPress support / Re: Importing text files into Quark with quark styles intact
« Last post by mbornbach on December 28, 2016, 02:49:34 PM »
It looks like simply saving the files as .docx files instead of .rtf files makes Quark happy. :)
9
Quark XPress support / Importing text files into Quark with quark styles intact
« Last post by mbornbach on December 28, 2016, 02:33:45 PM »
I'm trying to make our print production manager's life easier and I'm having trouble pulling text files into Quark with styles intact. I would like Quark to import the text and automatically apply the relevant styles.

I tried using rtf files and Microsoft Word styles. If I made a Microsoft Word style named "Headline" with 7 pt. XB Futura ExtraBold text, Quark would import the files with 7 pt. XB Futura ExtraBold text, but Quark would not apply the corresponding Quark style named "Headline"

I found an article that suggested using @tags within plain text files at http://www.tek-tips.com/viewthread.cfm?qid=657109. Unfortunately, when I tried that, it simply imported the words "@Headline:" instead of applying the headline style in Quark. If you have any advice on how to get text files to import into Quark with the relevant quark styles intact, I would appreciate it. (Don't say switch to InDesign, I tried to sell that and not everyone is as enthusiastic about the idea as I am, lol)

(Running Quark 9.5 and Microsoft Office 2011)

------------------------------------------------------------------------

For what it's worth, I have a script that is pulling info into the text files using Excel and Microsoft Word. (posted below in case anyone is curious). Aside from getting the formatting to work the way I want it to, the script works perfectly. Once I figure out how to work with imported text and styles in Quark, I'll add the relevant parts to the script and post the final script in the scripting section.


Code: [Select]
---------------------------------------------------------------------------------------------------
--PROMPTING THE USER TO SELECT THE FOLDER WITH THE EXCEL FILES
---------------------------------------------------------------------------------------------------

with timeout of 900 seconds

--Displaying a prompt asking the user to select the excel file with the information
set excel_folder to choose folder with prompt "Select the folder with the excel files"

tell application "Finder" to set excel_file_list to (every file of folder excel_folder whose name extension contains "xls") as alias list

---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------------
--OPENING THE WORKBOOK IN EXCEL
---------------------------------------------------------------------------------------------------

--Opening each Excel file
repeat with my_file in excel_file_list

set product_info to POSIX path of my_file
do shell script "open -a /Applications/Microsoft\\ Office\\ 2011/Microsoft\\ Excel.app " & quoted form of product_info
delay 10

---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------------
--GETTING INFO FROM EACH EXCEL ROW TO PASTE INTO WORD
---------------------------------------------------------------------------------------------------

--Repeating with every used row
set the_start_row to 2
tell application "Microsoft Excel"
tell active sheet
repeat with i from 1 to count of rows of used range
set current_row to i


--Setting the cell address for each info field
set sku_number_cell to "E" & current_row as string
set mfg_number_cell to "F" & current_row as string
set vendor_cell to "G" & current_row as string
set description_cell to "H" & current_row as string
set long_description_cell to "W" & current_row as string
set the_specs_cell to "X" & current_row as string
set the_url_cell to "Y" & current_row as string


--Getting the values from every cell address
if current_row is greater than or equal to the_start_row then
set sku_number to value of cell sku_number_cell as string
set mfg_number to value of cell mfg_number_cell as string
set the_vendor to value of cell vendor_cell as string
set the_description to value of cell description_cell as string
set long_description to value of cell long_description_cell
set the_specs to value of cell the_specs_cell
set the_url to value of cell the_url_cell

---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------------
--PASTING THE INFO INTO A MICROSOFT WORD DOCUMENT & APPLYING STYLES
---------------------------------------------------------------------------------------------------

--Doctoring the vendor name if it contains "/"
if the_vendor contains "/" then
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set text_items to text items of the_vendor
set AppleScript's text item delimiters to "_"
set the_vendor to text_items as Unicode text
set AppleScript's text item delimiters to astid
end if

--Setting the path in which to save the word document
set desktop_folder to path to desktop as string
set the output_path to desktop_folder & sku_number & "_" & the_vendor & ".rtf"


--Opening Microsoft Word
tell application "Microsoft Word"
activate


--Creating a new Word document
make new document


--Choosing which info to paste into word
set sale_price to "0099 SALE" & return
set description_heading to the_vendor & " " & the_description & return
set the_sku_number to sku_number & return
set regular_price to "Reg. 00.99"
set product_text to sale_price & description_heading & the_sku_number & regular_price


--Inserting/pasting that info into Word
insert text product_text at beginning of text object of active document


--Creating the basic paragraph style
set paragraph_style to make new Word style at active document with properties
{name local:"A Basic Price", style type:style type paragraph}
set line spacing of paragraph format of paragraph_style to "20"
set alignment of paragraph format of paragraph_style to align paragraph center
set space after of paragraph format of paragraph_style to "0.035"
set hyphenation to false


--Creating the Headline Character Style
set headling_style to make new Word style at active document with properties
{name local:"Headline", style type:style type character}
set name of font object of headling_style to "XB Futura ExtraBold"
set font size of font object of headling_style to "7"

--Applying Paragaph Style
set style of text object of paragraph 1 of selection to paragraph_style

--Finding Headline
set findRange to find object of selection
tell findRange
set description_part to execute find find text description_heading
log description_part
end tell


--Applying Headline Character Style
set style of text object of selection to "Headline"

--Saving and closing the document
try
save as active document file name output_path file format format rtf

--Overwriting file if it already exists
on error
try
set output_file to output_path as alias
tell application "Finder"
if exists output_file then
delete file output_file
tell application "Microsoft Word" to save as active document file name output_path file format format rtf
end if
end tell
end try
end try

tell active document to close saving no

end tell

log output_path

end if
end repeat
end tell
end tell
end repeat
end timeout
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
10
Quark XPress scripting / Re: Duplicating a Picture Box in Quark
« Last post by mbornbach on October 11, 2016, 05:07:23 PM »
Thanks! :) I got my complicated script working. Here's the full version in case anyone else is looking for something similar:

Code: [Select]
-----------------------------------------------------------------------------------------	
--HOW THIS SCRIPT WORKS
-----------------------------------------------------------------------------------------

--The script first creates a folder named "Publication Backups" on the user's desktop, if that folder doesn't already exist
--Then, the script saves a copy of each pre-prepped file that was dropped on the AppleScript droplet to the "Publication Backups" folder
--Then, the script sets the measurement units in Quark to inches
--Then, the script creates a list of images that are in the Quark document more than once
--After that, the script works with every picture box that is only in the document one time
--(This excludes picture boxes that already have a drop shadow, because those images would have been duplicated :))
----It fits the box to the picture, duplicates the picture box, resizes the duplicate so it is .08" high for most images,
----adds the drop shadow to the duplicate and groups the original picture box with the duplicated picture box.
--Finally, the script displays a dialog for the user when the script is finished prepping files

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------

on open of droppedfiles
with timeout of 1500 seconds -->Changing the timeout to 25 minutes. Default is 2 minutes, which can be way too little.


---------------------------------------------------------------------------------------------------
--CREATING BACKUP FOLDER IF IT DOESN'T EXIST
---------------------------------------------------------------------------------------------------

--Setting the path to the desktop
tell application "Finder"
set desktopFolder to path to desktop as string
end tell


--Creating the Publication Backups folder if it doesn't exist yet
if not my CheckForFolder(desktopFolder & "Publication Backups:") then
tell application "Finder"
make new folder at folder desktopFolder with properties {name:"Publication Backups"}
end tell
end if

--Setting the publication_backup folder to the folder named Publication Backups on the desktop
set publication_backup to desktopFolder & "Publication Backups:"

---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------------
--MAKING A BACKUP COPY OF EACH FILE BEFORE PROCESSING
---------------------------------------------------------------------------------------------------

--Starting the repeat loop
repeat with afile in droppedfiles


--Making a backup copy of each file to the desktop before processing
tell application "Finder"
activate
duplicate afile to publication_backup with replacing
end tell

---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------




-----------------------------------------------------------------------------------------
--OPENING THE QUARK FILE & SETTING THE MEASUREMENTS TO INCHES
-----------------------------------------------------------------------------------------

tell application "QuarkXPress"
activate


--Opening the file with warning dialogs suppressed
open afile as alias with Suppress All Warnings


tell document 1

set vertical measure to inches
set horizontal measure to inches

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------




-----------------------------------------------------------------------------------------
--BUILDING A LIST OF THE IMAGES THAT ARE IN THE DOCUMENT MORE THAN ONCE
-----------------------------------------------------------------------------------------

set originalList to {}

--Looping through every graphic to build a list that contains the name of every link
set theBoxes to every picture box
repeat with abox in theBoxes
set thepath to file path of image 1 of abox as string
set originalList to originalList & thepath
end repeat

--------------------------

--Building two lists of every link that has at least 2 copies in the document
set list1 to {}
--display dialog aLinkName & "-" & matchCount
repeat with x from 1 to count of items of originalList
set n to item x of originalList
--if n is in list2 and n is not in doubleImageList then set end of doubleImageList to n
set matchCount to my count_matches(originalList, n)
if matchCount is greater than 1 then
set list1 to list1 & n
end if
end repeat
--returns {AG123456.tif, AG123456.tif}

set list2 to {}
repeat with x from 1 to count of items of originalList
set n to item x of originalList
set matchCount to my count_matches(originalList, n)
if matchCount is greater than 1 then
set list2 to list2 & n
end if
end repeat
--returns {AG123456.tif, AG123456.tif}

--------------------------

--Building final list which only contains the name of duplicate images once
set doubleImageList to {}
repeat with x from 1 to count of items of list1
set n to item x of list1
if n is in list2 and n is not in doubleImageList then set end of doubleImageList to n
end repeat
--returns {AG123456.tif}

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------




-----------------------------------------------------------------------------------------
--CREATING A BLANK LIST FOR ALL THE BOXES THAT SHOULD HAVE A FULL SHADOW INSTEAD OF A TINY ONE AT THE BOTTOM
--This list will have items added to it as we loop through the images
-----------------------------------------------------------------------------------------

set full_shadow_image_list to {}

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------




-----------------------------------------------------------------------------------------
--ADDING ALL PICTURE BOXES THAT SHOULD BE SHADOWED TO A LIST
-----------------------------------------------------------------------------------------

--Looping through each picture box to see if it is in the document more than once
set pictureBoxes to every picture box
set shadowedIDList to {}
set unshadowedIDList to {}
repeat with i from 1 to the number of pictureBoxes

set pictureBox to item i of pictureBoxes
set imagePath to file path of image 1 of pictureBox as string


--Getting the bounds (coordinates) of the picture box
set y1_orig to coerce (item 1 of (bounds of pictureBox as list)) to real
set x1_orig to coerce (item 2 of (bounds of pictureBox as list)) to real
set y2_orig to coerce (item 3 of (bounds of pictureBox as list)) to real
set x2_orig to coerce (item 4 of (bounds of pictureBox as list)) to real


--Doing some math to determine the square inches of the picture box and image
set unshadowedBox_Height_orig to (y2_orig - y1_orig)
set unshadowedBox_Width_orig to (x2_orig - x1_orig)
set unshadowedBox_SquareInches to (unshadowedBox_Height_orig * unshadowedBox_Width_orig)


--Adding the box to the list if it is not in the document twice, it is in the 1_4cIMAGES folder and it has a blain number within the filename
if imagePath is not in doubleImageList and imagePath contains "1_4c IMAGES" and imagePath does not contain "Lifestyle" and imagePath does not contain "lifestyle" and imagePath does not contain ".eps" and imagePath does not contain ".ai" then
set unshadowedIDList to unshadowedIDList & uniqueID of pictureBox as string


--Moving the picture box to the front if it contains a logo
else if imagePath contains "2_LOGOS" then
move pictureBox to the front
end if

-----------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------




-----------------------------------------------------------------------------------------
--ADDING ALL PICTURE BOXES THAT SHOULD HAVE A FULL SHADOW TO A LIST
--(INSTEAD OF A TINY SHADOW AT THE BOTTOM)
-----------------------------------------------------------------------------------------

--Making sure that the tiny color swatches for clothing & sporting goods don't get shadowed
if imagePath contains "CL" and unshadowedBox_SquareInches is less than 1 then
set shadowBox to false
else if imagePath contains "SG" and unshadowedBox_SquareInches is less than 1 then
set shadowBox to false
else
set shadowBox to true
end if


--Adding the items that will get a shadow behind most of the image to a list
--(This would be items like shirts, jackets, sweaters that need a taller shadow)
set full_shadow_list to {"alfred", "Alfred", "bioworld", "bio world", "Bioworld", "Bio world", "BioWorld", "Bio World", "california", "California", "cgcg", "CgCg", "Cgcg", "CGCG", "columbia", "Columbia", "daniel", "Daniel", "erika", "Erika", "studioRay", "Studioray", "StudioRay", "TLBHolding", "TLB Holding", "tlb holding", "tlbholding", "TLBholding"}

repeat with full_shadow_item in full_shadow_list
if imagePath contains (contents of full_shadow_item) then set end of full_shadow_image_list to (imagePath as text)
end repeat

end repeat

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------




-----------------------------------------------------------------------------------------
--FITTING BOX TO PICTURE, UNGROUPING BOXES THAT SHOULD BE SHADOWED,
--DUPLICATING THE BOX, ADDING A DROP SHADOW TO THE DUPLICATED BOX
--RESIZING THE DUPLICATED BOX TO .08" HIGH AND GROUPING THE ORIGINAL BOX WITH THE DUPLICATE
-----------------------------------------------------------------------------------------

--Looping through the list of boxes that need to be duplicated and drop shadowed
set unshadowedBoxes to (every picture box whose uniqueID is in unshadowedIDList)
repeat with i from (number of unshadowedBoxes) to 1 by -1
set unshadowedBox to item i of unshadowedBoxes
set unshadowed_image_path to file path of image 1 of unshadowedBox as string


--Ungrouping boxes that will need a shadow
try
set group_boxes to every group box
repeat with group_box in group_boxes
if unshadowed_image_path of group_box is not in doubleImageList then
repeat until (count of group_boxes) is 0
tell group_box
set grouped to false
end tell
end repeat
end if
end repeat
end try

--------------------

--Getting the bounds (coordinates) of the picture box
set y1 to coerce (item 1 of (bounds of unshadowedBox as list)) to real
set x1 to coerce (item 2 of (bounds of unshadowedBox as list)) to real
set y2 to coerce (item 3 of (bounds of unshadowedBox as list)) to real
set x2 to coerce (item 4 of (bounds of unshadowedBox as list)) to real


--Getting the bounds (coordinates) of the image inside the picture box
set y1_image to coerce (item 1 of (actual bounds of image 1 of unshadowedBox as list)) to real
set x1_image to coerce (item 2 of (actual bounds of image 1 of unshadowedBox as list)) to real
set y2_image to coerce (item 3 of (actual bounds of image 1 of unshadowedBox as list)) to real
set x2_image to coerce (item 4 of (actual bounds of image 1 of unshadowedBox as list)) to real

--------------------

--Doing some math to determine the square inches of the picture box and image
set unshadowedBox_Height to (y2 - y1)
set unshadowedBox_Width to (x2 - x1)
set unshadowedBox_SquareInches to (unshadowedBox_Height * unshadowedBox_Width)
set unshadowedImage_Height to (y2_image - y1_image)
set unshadowedImage_Width to (x2_image - x1_image)
set unshadowedImage_SquareInches to (unshadowedImage_Height * unshadowedImage_Width)

--------------------

--Fitting the box to the picture if the picture is smaller, equal to or very slightly bigger than the picture box
if unshadowedImage_SquareInches is less than (unshadowedBox_SquareInches * 1.1) then

select unshadowedBox

try

--Pressing Command Shift C to activate the fit box to picture keyboard shortcut
tell application "System Events" to key code 8 using {shift down, command down}

on error

--Selecting "Fit Box To Picture" in the quark menu if the user does not have the fit box to picture keyboard shortcut
my do_submenu("QuarkXPress", "Style", "Fit Box To Picture")
end try

end if


--Unselecting the picture box
set selection to null

--------------------

--Getting the bounds (coordinates) of the picture box, now that it has been fit to the picture
set y1_final to coerce (item 1 of (bounds of unshadowedBox as list)) to real
set x1_final to coerce (item 2 of (bounds of unshadowedBox as list)) to real
set y2_final to coerce (item 3 of (bounds of unshadowedBox as list)) to real
set x2_final to coerce (item 4 of (bounds of unshadowedBox as list)) to real


--Getting the bounds (coordinates) of the image inside the picture box, now that it has been fit to the picture
set y1_image_final to coerce (item 1 of (actual bounds of image 1 of unshadowedBox as list)) to real
set x1_image_final to coerce (item 2 of (actual bounds of image 1 of unshadowedBox as list)) to real
set y2_image_final to coerce (item 3 of (actual bounds of image 1 of unshadowedBox as list)) to real
set x2_image_final to coerce (item 4 of (actual bounds of image 1 of unshadowedBox as list)) to real

--------------------

--Duplicating the picture box
set duplicateBox to duplicate unshadowedBox to after unshadowedBox

--------------------

--Getting the offset of the duplicate box
set props to properties of image 1 of duplicateBox
set {off1, off2} to (coerce offset of props to list)
set {Ys, Xs} to {coerce off1 to real, coerce off2 to real}


--------------------

--Checking if the picture box is rotated
set myProps to properties of duplicateBox
set myRotation to coerce (rotation of myProps) to string


--Making the duplicated shadowed box only .08" high
--unless the file path of the image contains certain vendor names
if text 1 of myRotation is "0" then
if unshadowed_image_path is not in full_shadow_image_list and unshadowed_image_path does not contain "FT" then

set new_y1_final to y2_final - 0.08 as number
set bounds of duplicateBox to {new_y1_final, x1_final, y2_final, x2_final}


--Doing some math to figure out where to move the image back to
--because Quark is being a pain and insists on moving the image with the box
set unshadowedBox_Height_final to (y2_final - y1_final)
set new_Ys to Ys - (unshadowedBox_Height_final - 0.08)
try
set offset of image 1 of duplicateBox to {new_Ys, Xs}
end try


--Making the duplicated shadowed box 0.35" tall if the path contains "FT"
else if unshadowed_image_path is not in full_shadow_image_list and unshadowed_image_path contains "FT" then

set new_y1_final to y2_final - 0.35 as number
set bounds of duplicateBox to {new_y1_final, x1_final, y2_final, x2_final}


--Doing some math to figure out where to move the image back to
--because Quark is being a pain and insists on moving the image with the box
set unshadowedBox_Height_final to (y2_final - y1_final)
set new_Ys to Ys - (unshadowedBox_Height_final - 0.35)
try
set offset of image 1 of duplicateBox to {new_Ys, Xs}
end try



--Making the duplicated shadowed box behind most of the image
--if the image path contains certain vendor names
else if unshadowed_image_path is in full_shadow_image_list then
set new_y1_final to y1_final + 0.1 as number
set bounds of duplicateBox to {new_y1_final, x1_final, y2_final, x2_final}


--Doing some math to figure out where to move the image back to
--because Quark is being a pain and insists on moving the image with the box
set unshadowedBox_Height_final to (y2_final - y1_final)
set new_Ys to -0.1
try
set offset of image 1 of duplicateBox to {new_Ys, Xs}
end try
end if
end if

--------------------

--This fixes the bug that opens the usage, missing font and replace font windows
tell application "System Events"
tell process "QuarkXPress"
set myUI to every UI element
try
if name of window 1 contains "Usage" then tell application "System Events" to key code 53
if name of window 1 contains "Font" then tell application "System Events" to key code 53
end try
end tell
end tell

--------------------

--The magic that adds the drop shadow
select duplicateBox
tell application "System Events" to key code 97 using {command down} -->Pressing Command F6 to activate the drop shadow item style
set selection to null

--------------------

--This fixes the bug that opens the usage, missing font and replace font windows again in case that window pops up twice
tell application "System Events"
tell process "QuarkXPress"
set myUI to every UI element
try
if name of window 1 contains "Usage" then tell application "System Events" to key code 53
if name of window 1 contains "Font" then tell application "System Events" to key code 53
end try
end tell
end tell

--------------------

--Grouping the original picture box with the duplicate box
try
set tool mode to drag mode
end try

set selection to null

set selected of duplicateBox to true
set selected of unshadowedBox to true
set grouped of group box 1 to true
set selection to null


end repeat


-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------




-----------------------------------------------------------------------------------------
--MOVING EVERY TEXT BOX THAT HAS A TRANSPARENT BACKGROUND TO THE FRONT
-----------------------------------------------------------------------------------------

set bgColor to null
set noColor to "None"

set textBoxes to every text box
repeat with i from 1 to number of textBoxes
set thisTextBox to item i of textBoxes
set textBoxProperties to properties of thisTextBox
set textBoxColor to color of textBoxProperties
if textBoxColor is "None" or textBoxColor is null or textBoxColor is "null" then
move thisTextBox to the front
end if
end repeat

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------




-----------------------------------------------------------------------------------------
--SAVING & CLOSING THE DOCUMENTS
-----------------------------------------------------------------------------------------

close saving yes

end tell --end of tell document 1 block
end tell --end of tell Quark block
end repeat --end of first repeat loop

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------



-----------------------------------------------------------------------------------------
--DISPLAYING A DIALOG TO THE USER THAT THE PAGES ARE DONE
-----------------------------------------------------------------------------------------

tell application "SystemUIServer" to display dialog "The pages are finished prepping." & return & return & "If you need to access the pre-prepped document, you will find it in the Publication Backups folder on your desktop." giving up after 4500 with icon note
end timeout
end open

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------


-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------

--Function to check if a folder exists
on CheckForFolder(thisFolder)
tell application "Finder"
return (exists folder thisFolder)
end tell
end CheckForFolder


--Function that counts the number of matches in a list
on count_matches(this_list, this_item)
set the match_counter to 0
repeat with i from 1 to the count of this_list
if item i of this_list is this_item then
set the match_counter to the match_counter + 1
end repeat
return the match_counter
end count_matches


--The UI Scripting select submenu function
--Thanks to http://www.macosxautomation.com/applescript/uiscripting/
on do_submenu(app_name, menu_name, menu_item)
try
-- bring the target application to the front
tell application app_name
activate
end tell
tell application "System Events"
tell process app_name
tell menu bar 1
pick menu bar item menu_name
tell menu bar item menu_name
tell menu menu_name
pick menu item menu_item
click menu item menu_item
end tell
end tell
end tell
end tell
end tell
return true
on error error_message
return false
end try
end do_submenu

Pages: [1] 2 3 4 5 ... 10