Recent Posts

Pages: 1 [2] 3 4 5 6 ... 10
11
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. :)
12
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
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
13
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

14
Quark XPress scripting / Re: Duplicating a Picture Box in Quark
« Last post by Jean-Marie Schwartz on October 11, 2016, 03:05:19 AM »
Hi! Here is how to group items. The idea is to have multiple items selected as to get the ability of grouping sth. Then you can either group those items like following or selecting menu item 10 of menu 5 (at least at my end). HTH.
Note that making new box at beginning in the following won't work (probably it would by naming the boxes within the properties).

Code: [Select]
tell application "QuarkXPress9"
tell document 1
set Box1 to make new picture box at end with properties {bounds:{"15 mm", "15 mm", "50 mm", "50 mm"}}
set Box2 to make new picture box at end with properties {bounds:{"50 mm", "50 mm", "100 mm", "100 mm"}}
try
set tool mode to drag mode
end try
set selection to null
-- Select the items to be grouped
set selected of Box1 to true
set selected of Box2 to true
set grouped of group box 1 to true
--set selection to null
end tell
end tell
beep 2
15
Quark XPress scripting / Re: Duplicating a Picture Box in Quark
« Last post by mbornbach on October 10, 2016, 05:23:41 PM »
Is it possible to group items in Quark? I found a bunch of information in the dictionary & applescript guide about working with boxes that are already grouped, but I'm not finding information on how to group the boxes.  I tried using system events to press command g after selecting the two boxes, but that's not grouping them. Or maybe I'm close with the system events solution if quark can't group boxes?

Code: [Select]
on open of droppedfiles
   
   tell application "QuarkXPress"
       activate
       repeat with afile in droppedfiles
           open afile as alias with Suppress All Warnings
           tell document 1
               
               --Looping through every picture box
               set pictureBoxes to every picture box
               repeat with i from (number of pictureBoxes) to 1 by -1
                   set pictureBox to item i of pictureBoxes
                   
                   
                   --Duplicating the picture box
                   set duplicateBox to duplicate pictureBox to after pictureBox
                   
                   
                   --Adding the drop shadow to the duplicated box
                   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 -->unselecting the duplicate box, otherwise the shadow is applied to both boxes
                   
                   
                   --Trying to select the two boxes
                   select duplicateBox
                   select pictureBox
                   
                   
                   --Trying to group the two boxes           
                   try
                       tell application "System Events" to key code 5 using {command down} -->Pressing Command G to group the items
                   on error
                       my do_submenu("QuarkXPress", "Item", "Group")
                   end try
                   
                   
                   set selection to null
                   
               end repeat
               
           end tell
       end repeat
   end tell
end open


--The UI Scripting select submenu function
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
16
Quark XPress scripting / Re: Duplicating a Picture Box in Quark
« Last post by Jean-Marie Schwartz on October 06, 2016, 02:02:46 AM »
Glad it works! Clearly it's not easy to get everything that is behind the scenes! To be honest I learnt such a lot from Michel!
17
Quark XPress scripting / Re: Duplicating a Picture Box in Quark
« Last post by mbornbach on October 05, 2016, 10:02:16 AM »
It's working! :) Thanks Jean-Marie. I didn't think to use offset. I was trying to use the image's bounds at one point, but that wasn't working like I'd hoped.
18
Quark XPress scripting / Re: Duplicating a Picture Box in Quark
« Last post by Jean-Marie Schwartz on October 05, 2016, 02:33:16 AM »
OK, I understand better. It sounds like the script doesn't behave like by-hand.
So you'll need to do maths to "keep" the picture like in place. If the original is at 0,0, then the maths is simple: offset the image minus the difference between original's top and duplicate's top. Does it make sense? The problem is if the original is already offset leftwards and upwards, you'll need to do more complicate maths (in scripting, that is getting position in Quark, coercing the values, do the maths and reposition the picture in the duplicate). Does all this make sense to you?
This piece of code shall give you the image offset:

Code: [Select]
tell application "QuarkXPress9"
tell document 1
set props to properties of image 1 of current box
set {off1, off2} to (coerce offset of props to list)
set {Ys, Xs} to {coerce off1 to real, coerce off2 to real}
end tell
end tell
19
Quark XPress scripting / Re: Duplicating a Picture Box in Quark
« Last post by mbornbach on October 04, 2016, 08:10:54 AM »
Thanks. I'm trying to move the top edge of the picture box down, so that instead of being 2-3 inches high, the duplicated box is only .08" high. It should leave the image in place, cropping it so only a tiny bit of the bottom of the duplicated image is showing. Instead it moves the image down when I resize the duplicate box, so that a tiny bit of the top of the image is showing. 

What we usually do, by hand, is duplicate a picture box, send it backward, add a drop shadow to the duplicated box and move the top handle of the duplicated box down. This way, we get this nice subtle drop shadow effect that only shows up on the bottom of the original image, instead of all the way around the image. Of course, this requires both the original image and the image in the duplicated picture box to remain in the exact same place.
20
Quark XPress scripting / Re: Duplicating a Picture Box in Quark
« Last post by Jean-Marie Schwartz on October 04, 2016, 02:31:46 AM »
Hi! Glad it works :-)

As for the content, I don't really get what you mean. Are you trying to keep the picture in place while moving one of the edges? (Like taking one handle of the middle of the box and go inside of the box?) If so, you need to subtract 0.08 from the image positon as well. Are you with me?

As for the locking part, here is a piece of code Matthias or someone else at Quark posted here (as far as I remember). Mind the word item (as you code) might be too wide for your requirements.

Code: [Select]
tell application "QuarkXPress9"
activate
tell document 1
try
set locked of (every generic box whose locked is true) to false

set format lock of (every image whose format lock is true) to false
set content lock of (every image whose content lock is true) to false

set format lock of (every story whose format lock is true) to false
set content lock of (every story whose content lock is true) to false
end try
end tell
end tell
beep 2
Pages: 1 [2] 3 4 5 6 ... 10