Re: scripting for Adobe Illustrator error
Re: scripting for Adobe Illustrator error
- Subject: Re: scripting for Adobe Illustrator error
- From: Jake Rowlands <email@hidden>
- Date: Tue, 18 Oct 2016 12:36:49 -0400
Posting the entire script. Error now is error "The variable WindowPosition is not defined." number -2753 from "WindowPosition" of line 71.
- tell application "Adobe Illustrator"
- set clicker to {23, 46}
- --set user interaction level to interact with all
- try
- if contents of selection is not "Client" then
-
- error number -128
- end if
- on error
- display dialog "Please select the word \"Client\"" giving up after 1.5
- error number -128
- end try
-
- activate
- set x to properties of selection
- delay 0.15
- tell application "System Events"
- keystroke "a" using command down
- end tell
- redraw
- set y to properties of selection
- set TheContent to contents of y
- set TheSize to size of x
- set TheSelection to item 1 of selection of y
- set TheContainer to container of y
- set selection to {}
- --set selection to page item 1 of document 1
- redraw
-
-
-
- tell document 1
- set TheFrame to every text frame whose contents is TheContent
- end tell
-
-
- --say "window"
-
- tell application "System Events"
- tell process "Adobe Illustrator"
- --beep
- set frontmost to true
- my do_submenu("Adobe Illustrator", "Window", "Tools", "Default")
- set Sizes1 to size of every window
- my do_submenu("Adobe Illustrator", "Window", "Tools", "Default")
- set Sizes2 to size of every window
- --beep
- if length of Sizes1 is not length of Sizes2 then
- if length of Sizes1 is greater than length of Sizes2 then
- set TheSize to item 1 of my RemoveComonList(Sizes1, Sizes2)
- else
- set TheSize to item 1 of my RemoveComonList(Sizes2, Sizes1)
- end if
- --beep
- set TOOLS to every window whose size is TheSize
- if TOOLS is {} then
- my do_submenu("Adobe Illustrator", "Window", "Tools", "Default")
- set TOOLS to every window whose size is TheSize
- end if
- --beep
- tell item 1 of TOOLS
- set WindowPosition to position
- set item 1 of WindowPosition to (item 1 of WindowPosition) + (item 1 of clicker)
- set item 2 of WindowPosition to (item 2 of WindowPosition) + (item 2 of clicker)
- end tell
- end if
- end tell
- end tell
- --say "Click"
-
- my MouseClick(item 1 of WindowPosition, item 2 of WindowPosition, 1)
- delay 1
- set TheContent to contents of the selection
-
- --beep
-
- set TheContent to my stringtolist(TheContent, return)
-
-
- set TheResult to {}
-
- set eventDate to current date
- set dayInteger to day of eventDate as integer as string
- set monthInteger to month of eventDate as integer as string
- set yearInteger to year of eventDate as integer as string
- if (count of every character of dayInteger) is 1 then
- set dayInteger to "0" & dayInteger
- end if
- if (count of every character of dayInteger) is 1 then
- set dayInteger to "0" & dayInteger
- end if
- if (count of every character of monthInteger) is 1 then
- set monthInteger to "0" & monthInteger
- end if
- set yearInteger to (items 3 through 4 of every character of yearInteger) as string
- set dateString to monthInteger & "." & dayInteger & "." & yearInteger
- --beep
- ----PRINT SCALE
-
- set SlugContents to my stringtolist(TheContent, return)
- set SlugBlack to {cyan:0.0, magenta:0.0, yellow:0, black:100}
- set AutoSlugList to {"xscalex", "xdateLRx", "xfilex", "xjobdescx", "xjobx", "xdateAx", "xdiex", "xdiesizex"}
- --set user interaction level to interact with all
- set ArtboardDims to artboard rectangle of artboard 1 of document 1
- set theWidth to width of document 1
- set theHeight to height of document 1
- set ThePath to file path of document 1
- set Parentfolder to item 2 of my FolderPathtoList(ThePath, 0, 1)
- --set xjobx to items 1 thru 10 of every item of Parentfolder as string
- set xjobx to item 1 of my stringtolist(Parentfolder, " ")
-
- set xjobdescx to items ((count of every item of xjobx) + 2) thru (count of every item of Parentfolder) of every item of Parentfolder as string
- set xfilex to name of document 1
- if theWidth is greater than theHeight then
- set ScaleV to round (776 / theHeight * 100)
- set scaleH to round (1198 / theWidth * 100)
- if scaleH is greater than ScaleV then
- set PrintScale to ScaleV
- else
- set PrintScale to scaleH
- end if
- else
- set ScaleV to round (1198 / theHeight * 100)
- set scaleH to round (776 / theWidth * 100)
- if scaleH is greater than ScaleV then
- set PrintScale to ScaleV
- else
- set PrintScale to scaleH
- end if
- end if
-
- if PrintScale > 99 then
- set PrintScale to 100
- end if
-
- set xscalex to PrintScale & "%"
-
- --beep
- set this_text to name of document 1
- set THE_TEXT to this_text as string
-
-
-
-
-
-
- -----------------------------Name Switch
-
- set userName to long user name of (system info)
- set userName to my name_switch(userName, "afelch", "AF")
- set userName to my name_switch(userName, "jrowlands", "JR")
- set userName to my name_switch(userName, "bpope", "BP")
- set userName to my name_switch(userName, "rbaer", "RB")
- set userName to my name_switch(userName, "bkoski", "BK")
- set userName to my name_switch(userName, "jelkins", "JE")
- set xdateLRx to dateString & " " & userName as string
-
- (*
- set thedisplay to {"Job: ", xjobx as string, return, "Description: ", xjobdescx, return, "File: ", xfilex, return, "Artist: ", xdateAx, return, "Last Rev: ", xdateLRx, return, "Print Out Date: ", xdatePOx, return, "Proof Scale: ", xscalex}
-
- display dialog (thedisplay as string) buttons {"Cancel", "Continue"} default button 2
- *)
- ------------
-
-
-
-
- (*
- repeat with fr from 1 to count of AutoSlugList
- try
- set fill color of every character of every word of text frame (item fr of AutoSlugList) of current document to SlugBlack
- on error
- set xfilex to false
- end try
- end repeat
-
- *)
-
- --beep
- set prejob to "Job#: "
- set prefile to "File Name: "
- set predatelr to "Last Revision: "
- set prescale to "ART IS: 100% PROOF IS: "
- set end of TheResult to item 1 of TheContent
- set end of TheResult to return
- set end of TheResult to prejob & xjobx
- set end of TheResult to return
- set end of TheResult to xjobdescx
- set end of TheResult to return
- set end of TheResult to "File Name: " & xfilex
- set end of TheResult to return
- set end of TheResult to item 5 of TheContent
- set end of TheResult to return
- set end of TheResult to "Last Revision: " & xdateLRx
- set end of TheResult to return
- set end of TheResult to item 7 of TheContent
- set end of TheResult to return
- set end of TheResult to item 8 of TheContent
- set end of TheResult to return
- set end of TheResult to item 9 of TheContent
- set end of TheResult to return
- set end of TheResult to item 10 of TheContent
- set end of TheResult to return
- set end of TheResult to item 11 of TheContent
- set end of TheResult to return
- set end of TheResult to prescale & xscalex
- set TheResult to TheResult as string
- display alert TheResult
-
- set contents of item 1 of TheFrame to TheResult
- my ChangeFont(1, length of TheResult, "HelveticaNeueLTStd-Cn", index of TheContainer)
- set theStart to 1
- set theEnd to 7
- my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
- set theStart to (length of item 1 of TheContent) + 1
- set theEnd to theStart + (length of prejob)
- my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
- set theStart to theEnd + (length of xjobdescx) + (length of xjobx) + 2
- set theEnd to theStart + (length of prefile)
- my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
- set theStart to theEnd + (length of xfilex) + 2
- set theEnd to theStart + 13
- my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
- set theStart to theEnd + (length of item 5 of TheContent) - 13
- set theEnd to theStart + (length of predatelr)
- my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
- set theStart to theEnd + (length of xdateLRx) + 1
- set theEnd to theStart + (15)
- my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
- set theStart to theEnd + (length of item 7 of TheContent) - 14
- set theEnd to theStart + 6
- my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
- set theStart to theEnd + (length of item 8 of TheContent) - 5
- set theEnd to theStart + 6
- my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
- set theStart to theEnd + (length of item 9 of TheContent) - 5
- set theEnd to theStart + (length of item 10 of TheContent) + 13
- my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
-
- set theStart to theEnd + (length of item 11 of TheContent) - 11
- set theEnd to theStart + 8
- my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
- set theStart to theEnd + 5
- set theEnd to theStart + 10
- my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
-
- --------------
-
-
-
-
-
-
-
- --display dialog "Please select the word \"Client\"" giving up after 0.5
-
-
- end tell
- on RemoveComonList(list1, list2)
-
- set list3 to {}
- set templist1 to {}
- set templist2 to {}
- repeat with fr from 1 to count of list1
- set end of templist1 to item fr of list1 as string
- end repeat
- --set templist1 to reverse of templist1
- repeat with fr from 1 to count of list2
- set end of templist2 to item fr of list2 as string
- end repeat
- --set templist2 to reverse of templist2
- repeat with x from 1 to count of items of list1
-
-
- repeat with y from 1 to count of list1
- set n to item y of templist1
- if n is not in templist2 then set end of list3 to item y of list1
- end repeat
- end repeat
-
- return list3
- end RemoveComonList
- on do_submenu(app_name, menu_name, menu_item, submenu_item)
- try
- -- bring the target application to the front
-
- tell application "System Events"
- tell process app_name
- set frontmost to true
- tell menu bar 1
- tell menu bar item menu_name
- tell menu menu_name
- tell menu item menu_item
- tell menu menu_item
- click menu item submenu_item
- end tell
- end tell
- end tell
- end tell
- end tell
- end tell
- end tell
- return true
- on error error_message
- return false
- end try
- end do_submenu
- on FolderPathtoList(myPath, TrimFront, TrimBack)
- set FolderPath to {}
- ----beep
- set oldDelimiters to AppleScript's text item delimiters -- always preserve original delimiters
- ----beep
- set AppleScript's text item delimiters to {":"}
- set pathItems to text items of (myPath as text)
- ----beep
- set TF to (TrimFront as number) + 1
- set TB to ((count of pathItems) - TrimBack as integer) as integer
- set AppleScript's text item delimiters to oldDelimiters
- return items TF thru TB of pathItems as list
- end FolderPathtoList
- on name_switch(theVariable, Old, new)
- if theVariable is Old then
- set theVariable to new
- else
- set theVariable to theVariable
- end if
- end name_switch
- on stringtolist(TheString, TheDelimiter)
- set theList to {}
- set oldDelimiters to AppleScript's text item delimiters -- always preserve original delimiters
- set AppleScript's text item delimiters to TheDelimiter as list
- set theList to text items of (TheString as text)
-
- set AppleScript's text item delimiters to oldDelimiters
- return theList
- end stringtolist
- on ChangeFont(CharStart, CharEnd, TheFont, TheStory)
- tell application "Adobe Illustrator"
- set text font of text from character CharStart to character CharEnd of story TheStory of document 1 to text font TheFont
- end tell
- end ChangeFont
- on MouseClick(x, y, MouseButton)
- do shell script "
- /usr/bin/python <<END
- import sys
- import time
- from Quartz.CoreGraphics import *
- def mouseEvent(type, posx, posy):
- theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
- CGEventPost(kCGHIDEventTap, theEvent)
- def mousemove(posx,posy):
- mouseEvent(kCGEventMouseMoved, posx,posy);
- def mouseclick(posx,posy):
- mouseEvent(kCGEventLeftMouseDown, posx,posy);
- mouseEvent(kCGEventLeftMouseUp, posx,posy);
- ourEvent = CGEventCreate(None);
- currentpos=CGEventGetLocation(ourEvent); # Save current mouse position
- mouseclick(" & x & "," & y & ");
- mousemove(int(currentpos.x),int(currentpos.y)); # Restore mouse position
- END"
- end MouseClick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden