Author Topic: Still need some help...  (Read 1754 times)

0 Members and 1 Guest are viewing this topic.

Offline Jean-Marie Schwartz

  • Sr. Member
  • ****
  • Posts: 436
  • Karma: 6
  • Gender: Male
Still need some help...
« on: July 05, 2007, 09:06:47 AM »
Here I am back with the entire code of the script making the bar code and importing it in Quark along with the text box reading ISBN etc. + the price in euro.  8)
My big problem -for there is always a problem somewhere!- is that running the script from the Script menu of Quark seems to stop before or at activating Illustrator app. Is there any reason? a workaround?
BTW thank you for the fix, Michel and Mark.
Here we go:
Quote
--> PARTIE I : Cette 1re partie réclame le numéro d'ISBN et remplit les variables

display dialog "Quel est le numéro d'ISBN ? (3 chiffres + 1)" default answer ""
set cle_ISBN to text returned of result --XXXX
set ISBN13 to "978287356" & cle_ISBN --978287356XXXX
set codename to "EAN13 978287356" & cle_ISBN as text --EAN13 978287356XXXX
set nom_fichier to text 1 thru -2 of codename --EAN13 978287356XXX
set CBpath to (path to documents folder as Unicode text) & "CODES BARRES:" & nom_fichier & ".eps" as text --("~:Documents:CODES BARRES:" & nom_fichier & ".eps")
set cle_3_1 to (text 1 thru 3 of cle_ISBN) & "-" & (text 4 of cle_ISBN) as text

--> PARTIE II : Cette partie crée le code barres et l'enregistre dans le dossier CODES BARRES
--(*
activate application "Code Barre X"
tell application "System Events" to tell process "Code Barre X"
     keystroke "n" using command down
     tell window "Code Barre X" to repeat until exists -- attend que la fenêtre "Code Barre X" s'ouvre
          delay 0.2
     end repeat
     keystroke ISBN13
     delay 0.2
     keystroke return -- ou (ASCII character 13)
     delay 0.2
     keystroke "s" using command down
     tell window "Enregistrer : Code Barre X" to repeat until exists -- attend que la fenêtre "Enregistrer : Code Barre X" s'ouvre
          delay 0.2
     end repeat
     keystroke nom_fichier
     keystroke return -- ou (ASCII character 13)
     repeat while exists window "Enregistrer : Code Barre X"
          delay 0.2 -- si une fenetre s'ouvre demandant de remplacer, c'est que le fichier existe déja, ceci va remplacer le fichier existant.
          if button "Remplacer" exists then click button "Remplacer"
     end repeat
end tell
quit application "Code Barre X"

--set thepath to "~:Documents:CODES BARRES:"
--set codename to "EAN13 978287356349" as text
--set filename to (codename & ".eps") as text
--set filealias to (thepath & filename) as alias
--*)


--(*
--> PARTIE III : Cette partie repasse le CB dans Illustrator pour l'avoir en CMJN au format 38 x 16 mm
tell application "Illustrator CS"
     activate
     open file ("~:Documents:CODES BARRES:" & nom_fichier & ".eps")
     tell application "System Events"
          tell process "Illustrator"
               -- = click menu item "Format de document..." of menu "Fichier" of menu bar 1
               click menu item 22 of menu 1 of menu bar item 3 of menu bar 1
               keystroke tab
               keystroke "38"
               keystroke tab
               keystroke "16"
               keystroke return
          end tell
     end tell
     do script "Code barres (F1)" from "Scripts JM"
     save current document as eps with options {class:EPS save options, preview:BW TIFF, include document thumbnails:true, embed all fonts:true, CMYK PostScript:true, PostScript:level 2} with replacing
     quit
end tell
--*)


--> PARTIE IV : Cette partie crée un bloc image dans le document XPress et y importe le CB ; puis un bloc texte est créé juste au-dessus avec le numéro d'ISBN et le prix
tell application "QuarkXPress Passport"
     activate
     tell page 1 of document 1
          -- bounds of box = top of box, left of box, bottom of box, right of box (attention, entre guillemets et avec espace avant unité !)
          set CodeBarreBox to make picture box at beginning with properties {bounds:{"50 mm", "15 mm", "66 mm", "53 mm"}, color:"Blanc"}
          --display dialog "Chemin vers CB = " & (CBpath as text)
          tell CodeBarreBox
               try
                    set image 1 to alias CBpath
               on error
                    set image 1 to (choose file with prompt "Merci de localiser le code à barres.")
               end try
               set bounds of image 1 to centered
          end tell
          -- bounds of box = top of box, left of box, bottom of box, right of box (attention, entre guillemets et avec espace avant unité !)
          set ISBNBox to make text box at beginning with properties {bounds:{"42 mm", "15 mm", "50 mm", "53 mm"}, color:"Blanc"}
          tell ISBNBox
               set vertical justification to centered
          end tell
          tell story 1 of ISBNBox
               set size to 9
               set leading to 10
               set justification to centered
               set contents of it to "ISBN 978-2-87356-" & cle_3_1 & return & "Prix TTC : X,XX E"
               set font of last character to "Euro Sans"
          end tell
     end tell
     try
          set tool mode to drag mode
     end try
     set selection to null
     -- Select the items to be grouped
     set selected of CodeBarreBox to true
     set selected of ISBNBox to true
     -- Group them
     select menu item 10 of menu 5
     --set selection to null
end tell

beep 2
« Last Edit: September 09, 2011, 02:51:50 AM by Jean-Marie Schwartz »
Jean-Marie Schwartz
May the Schwartz be with you :-)

= Mac Pro Quad-Core Intel 2.8 GHz • 10 Go 1066 MHz DDR3 • Mac OS 10.8.5 • QuarkXPress 9.5.4.1 • Adobe CS5 =

Offline larsen67

  • Sr. Member
  • ****
  • Posts: 459
  • Karma: 10
  • Gender: Male
Re: Still need some help...
« Reply #1 on: July 05, 2007, 10:04:48 AM »
JMS, in line 8 of your code you set variable "CBpath" to a file path "as text" Because you have done this you can re-use this variable elsewhere in your script (if its green in SE then you've set or copied information into this variable, else it would be undifined.

So in your illustrator tell block you can change your open file line to the following:

open file CBpath as alias

-- The "as alias" is required as you previously saved the path stored as text in your variable "CBpath"

Offline Jean-Marie Schwartz

  • Sr. Member
  • ****
  • Posts: 436
  • Karma: 6
  • Gender: Male
Re: Still need some help...
« Reply #2 on: July 05, 2007, 10:57:13 AM »
Hum! Thank you for the correction (which I now made in my code) but it still doesn't work: Illustrator does not launch. (I typed xyz between the quotes as to have SE to set the name by itself so the app name is normally correct.)
Is there another way of activating an app?
Jean-Marie Schwartz
May the Schwartz be with you :-)

= Mac Pro Quad-Core Intel 2.8 GHz • 10 Go 1066 MHz DDR3 • Mac OS 10.8.5 • QuarkXPress 9.5.4.1 • Adobe CS5 =

Offline Publi-Script

  • Administrator
  • Hero Member
  • *****
  • Posts: 596
  • Karma: 16
  • Gender: Male
  • Automate your Life!
    • Publi-Script.com
Re: Still need some help...
« Reply #3 on: July 05, 2007, 11:02:39 AM »
Hi Jean-Marie,

Before getting any further, try to see if the script will run under Apple's Script menu.

I lost count of scripts refusing to work properly when using Quark's Script menu, in fact I no longer use it.
Michel Lemieux
Forum Administrator
-------------------------
OS X 10.6.4
Quark 6.5 / 7.5 / 8.1.6
Adobe Design Premium CS / CS2 / CS3 / CS4 / CS5
Script Debugger 4.5

Offline Jean-Marie Schwartz

  • Sr. Member
  • ****
  • Posts: 436
  • Karma: 6
  • Gender: Male
Re: Still need some help...
« Reply #4 on: July 05, 2007, 02:36:02 PM »
Before getting any further, try to see if the script will run under Apple's Script menu.

I lost count of scripts refusing to work properly when using Quark's Script menu, in fact I no longer use it.
Thanks for the input, Michel. I'm not at work right now and shall test it tomorrow before I'm off on vacation.
On the MacBidouille forum, the same guy as tomorrow suggested to have Illu launched prior and just skip the activate line. Shall give all that a shot. Thanks for your help.
(Have you noticed I inserted a chunk of code you posted on the other forum a while back? I've tried to select the 2 boxes in Quark and group them to no avail. So I searched the Web and came accross your solution -but to group them I had to select the menu item rather than the line you wrote. The important thing is that it work for me -even if the best script is the more universal and runs on whatever Mac...)
Jean-Marie Schwartz
May the Schwartz be with you :-)

= Mac Pro Quad-Core Intel 2.8 GHz • 10 Go 1066 MHz DDR3 • Mac OS 10.8.5 • QuarkXPress 9.5.4.1 • Adobe CS5 =