(*
force safari to load url. if url is loaded use javascript to submit form.
*)
tell application "Safari" to open location "http://www.heise.de"
if my page_loaded(20) is true then
tell application "Safari"
activate
tell document 1
do JavaScript "document.getElementById('suchfeld').q.value='Applescript';
document.getElementById('suchfeld').submit()"
if my page_loaded(20) is true then
do JavaScript "var b = new Array();
for (var i=0;i<document.getelementbyid('filter').getelementsbytagname('a').length;i++) if="" documentgetelementbyid="" filter="" getelementsbytagname="" a="" iinnerhtmlindexof="" ct="">-1)
{
window.location.href = document.getElementById('filter').getElementsByTagName('a')[i].getAttribute('href')
break;
}
}
"
end if
end tell
end tell
else
display dialog "There was a timeout"
end if
on page_loaded(timeout_value)
set i to 0
delay 1
tell application "Safari"
repeat until (do JavaScript "document.readyState" in document 1) is "complete"
delay 0.5
if i > timeout_value then return false
set i to i + 1
end repeat
return true
end tell
end page_loaded
</document.getelementbyid('filter').getelementsbytagname('a').length;i++)>
set TargetFolder to choose folder with prompt "Please choose the folder where to save the PDFs"
tell application "QuarkXPress"
set MyProject to object reference of project 1
tell MyProject
repeat with i from 1 to count of layout space
try
export layout space i as "PDF" in ((TargetFolder as string) & name of layout space i & ".pdf")
on error errMsg number errNum
end try
end repeat
end tell
end tell
set piclist to {}
set datlist to {}
global missed
set missed to {}
global dat, datlist, fileID
global textFile, available
set SourceFile to (choose file with prompt "Choose any quark document file...")
set textFile to (choose file with prompt "Choose text file ...")
set thepath to choose folder with prompt "Select folder to images in..."
tell application "Finder"
if (file textFile exists) then
set fileID to open for access textFile
try
set myfilecontents to read textFile
on error
display dialog "Check the text file..."
return
end try
close access textFile
end if
end tell
tell application "QuarkXPress"
try
open SourceFile use doc prefs yes remap fonts no do auto picture import no
on error
display dialog "check the file is already opened..."
return
end try
tell document 1
set pb to count of images
set the Tmppara_list to every paragraph of myfilecontents
repeat with i from 1 to count of paragraph of myfilecontents
set Tmpln to i
set Tmp_p1 to paragraph i of myfilecontents
set TmpTextpara to Tmp_p1
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to tab
--set subject to text items of "A B"
set subject to text items of TmpTextpara
set srcImg to item 1 of subject
set desImg to item 2 of subject
set text item delimiters of AppleScript to prevTIDs
--end repeat
set available to false
repeat with i from 1 to count of images
tell image i
set ImageBox to object reference of picture box 1
-- Copy writable properties
set Img_file_path to (file path) as text
if (Img_file_path ? "null" and Img_file_path ? "no disk file") then
set theImageName to my NameFromPath(Img_file_path)
if (theImageName ? "null" and theImageName ? "no disk file") then
if theImageName = srcImg then
set available to true
if not missing then
set Img_angle to angle
set Img_color to color
set Img_greek_pictures to greek pictures
set Img_image_trap to image trap
set Img_invert_runaround to invert runaround
--set Img_model to model
set Img_name to name
--set Img_negative to negative
set Img_offset to offset
set Img_scale to scale
set Img_screen to screen
set Img_screen_angle to screen angle
set Img_screen_frequency to screen frequency
set Img_screen_function to screen function
set Img_shade to shade
set Img_show_half_tone to show half tone
set Img_skew to skew
set Img_suppress_printing to suppress printing
set Img_file_path to (file path) as text
tell application "Finder"
try
set the datlist to files of thepath
end try
repeat with dat in datlist
set fname to name of dat as string
if fname = srcImg then
set name of dat to desImg
exit repeat
end if
end repeat
end tell
-- Get new image path
set Img_file_path to (file path) as text
set Img_file_path to my FindReplace(srcImg, desImg, Img_file_path)
-- Re-import picture
try
set image 1 of ImageBox to file Img_file_path
-- Re-set image properties
tell image 1 of ImageBox
set angle to Img_angle
set color to name of Img_color
set greek pictures to Img_greek_pictures
set image trap to Img_image_trap
set invert runaround to Img_invert_runaround
--set model to Img_model
set name to Img_name
--set negative to Img_negative
set offset to Img_offset
set scale to Img_scale
set screen to Img_screen
set screen angle to Img_screen_angle
try
set screen frequency to Img_screen_frequency
end try
set screen function to Img_screen_function
set shade to Img_shade
set show half tone to Img_show_half_tone
set skew to Img_skew
set suppress printing to Img_suppress_printing
end tell
end try
end if
--else
--available = false
end if
end if
end if
end tell
end repeat
if available = false then
--display dialog srcImg
set missed to missed & srcImg & return
end if
end repeat
end tell
save document 1
--copy (choose file name default name "missed" & ".txt") as string to dataFile
set SourceFile to SourceFile as string
set dataFile to my FindReplace(".qxd", ".txt", SourceFile)
try
open for access file (dataFile) with write permission
set eof of file (dataFile) to 0
write item 1 of missed to file (dataFile) starting at 0
repeat with i from 2 to length of missed
try
write item i of missed to file (dataFile)
end try
end repeat
close access file (dataFile)
on error errtext number errNum
close access file (dataFile)
tell application "QuarkXPress"
activate
-- display dialog errtext
display dialog "No missed files..."
end tell
end try
display dialog "completed"
return
end tell
on FindReplace(FindWhat, ReplaceBy, ThisString)
copy the text item delimiters to OldDelims
set the text item delimiters to {FindWhat}
set TempList to every text item of ThisString
set the text item delimiters to {ReplaceBy}
set NewString to TempList as text
set the text item delimiters to OldDelims
return NewString
end FindReplace
on NameFromPath(theImagePath)
set theOffset to the offset of ":" in (the reverse of every character of theImagePath) as string
set theImageName to (characters -(theOffset - 1) thru -1 of theImagePath) as string
return theImageName
end NameFromPath
(*
this in a older examples that i found in the web...
*)
on open fileList
repeat with aDoc in fileList
set filePath to aDoc as string
if filePath ends with ":" then
else
set fileInfo to (info for file filePath)
if file type of fileInfo is in {"XDOC", "XPRT"} then
set docName to name of fileInfo
set docVers to getVers(filePath)
display dialog "Die Version des Dokuments " & docName & ": " & docVers & "." buttons "OK" default button 1 with icon 1
end if
end if
end repeat
end open
on getVers(filePath)
set versionClue to read file filePath for 12
if versionClue contains "MM" then
if versionClue ends with "?" then
return "QuarkXPress 3.x (Mac)"
else if versionClue ends with "A" then
return "QuarkXPress 4.x (Mac)"
else if versionClue ends with "B" then
return "QuarkXPress 5.x (Mac)"
else if versionClue ends with "C" then
return "QuarkXPress 6.x (Mac)"
else
return "unbekannt (Mac)"
end if
else if versionClue contains "II" then
set testChar to character 11 of versionClue
if character 11 of versionClue = "?" then
return "QuarkXPress 3.x (Windows)"
else if character 11 of versionClue = "A" then
return "QuarkXPress 4.x (Windows)"
else if character 11 of versionClue = "B" then
return "QuarkXPress 5.x (Windows)"
else if character 11 of versionClue = "C" then
return "QuarkXPress 6.x (Windows)"
else
return "unbekannt (Windows)"
end if
end if
end getVers
(*
qxp_coerce_01.applescript
Coerce the swiss army knife to convert measurement units.
*)
tell application "QuarkXPress Passport"
tell document 1
-- get bounds of generic box 1 of document 1.
set {t, l, b, r} to bounds of generic box 1 as list
-- for example t (top of bounds) would be coerced from
-- vertical measurement ('FXVM') of QuarkXPress to a real number
-- "8,467 mm" => 8.466644287109
set t_as_real to coerce t to real
-- for example l (left of bounds) would be coerced from
-- horizontal measurement ('FXHM') of QuarkXPress to a string
-- "20,461Â mm" => "20,461Â mm"
set l_as_string to coerce l to string
end tell
end tell
(*
qxp_duplicate_01.applescript
Duplicates an object.
*)
tell application "QuarkXPress Passport"
-- Example 1: copy a object from layout space 1 to layout space 2
tell project 1
duplicate generic box 1 of layout space 1 to beginning of layout space 2
end tell
-- Example 2: copy a object from document 1 to document 2
duplicate generic box 1 of layout space 1 of project 1 to beginning of layout space 1 of project 2
end tell
(*
qxp_assign_characterpec_01.applescript
Assign characterspec to a specific text.
*)
tell application "QuarkXPress Passport"
tell document 1
set character style of every text of every story whose it = "MY_TEXT_TO_FORMAT" to character spec "THE_CHARCTERSPEC_NAME"
end tell
end tell
(*
qxp_assign_stylespec_01.applescript
Assign stylespec to an paragraph in a text box
*)
tell application "QuarkXPress Passport"
tell document 1
set style sheet of paragraph 1 of text box 1 to style spec "THE_STYLESPEC_NAME"
end tell
end tell
(* qxp_searchreplace_01.applescript *)
tell application "QuarkXPress Passport"
tell document 1
set text of every text of every story where it is "OLD" to "NEW"
end tell
end tell
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the ...
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.