Working with script menu actions. Adobe InCopy CS6
Add to My manuals108 Pages
Adobe® InCopy® CS6 empowers copywriters and editors to collaborate seamlessly on copy-intensive projects with designers using Adobe® InDesign®. With InCopy, you can write, edit, and style text in a copyflow workspace that’s specifically designed for editorial workflows. Plus, you can easily integrate with InDesign to place and edit copy within page layouts. Whether you’re working on a magazine, newspaper, or marketing collateral, InCopy can help you create high-quality copy efficiently and effectively.
advertisement
![Working with script menu actions. Adobe InCopy CS6 | Manualzz Working with script menu actions. Adobe InCopy CS6 | Manualzz](http://s3.manualzz.com/store/data/053735945_1-62d2bfb0177c558e8e074a39acf5ba05-360x466.png)
Menus Working with script menu actions 76 the wording of menu item, or performs other tasks related to the menu. This mechanism is used internally to change the menu listing of available fonts, recent documents, or open windows.
Working with script menu actions
You can use ScriptMenuAction to create a new MenuAction whose behavior is implemented through the script registered to run when the onInvoke Event
is triggered.
The following script shows how to create a ScriptMenuAction and attach it to a menu item (for the complete script, see MakeScriptMenuAction). This script simply displays an alert when the menu item is selected.
Set myInCopy = CreateObject("InCopy.Application")
Set mySampleScriptAction = myInCopy.ScriptMenuActions.Add("Display Message")
Set myEventListener = mySampleScriptAction.EventListeners.Add("onInvoke",
"c:\message.vbs")
Set mySampleScriptMenu = myInCopy.Menus.Item("$ID/Main").Submenus.Add("Script Menu
Action")
Set mySampleScriptMenuItem = mySampleScriptMenu.MenuItems.Add(mySampleScriptAction)
The script file message.vbs
contains the following code:
MsgBox("You selected an example script menu action.")
To remove the Menu , Submenu , MenuItem , and ScriptMenuAction created by the preceding script, run the following script fragment (from the RemoveScriptMenuAction tutorial script):
Set myInCopy = CreateObject("InCopy.Application")
Set mySampleScriptAction = myInCopy.ScriptMenuActions.Item("Display Message") mySampleScriptAction.Delete
Set mySampleScriptMenu = myInCopy.Menus.Item("$ID/Main").Submenus.Item("Script Menu
Action") mySampleScriptMenu.Delete
You also can remove all ScriptMenuAction , as shown in the following script fragment (from the
RemoveAllScriptMenuActions tutorial script). This script also removes the menu listings of the
ScriptMenuAction
, but it does not delete any menus or submenus you might have created.
Set myInCopy = CreateObject("InCopy.Application")
For myCounter = myInCopy.ScriptMenuActions.Count To 1 Step -1 myInCopy.ScriptMenuActions.Item(myCounter).Delete
Next
You can create a list of all current
ScriptMenuActions
, as shown in the following script fragment (from the GetScriptMenuActions tutorial script):
Set myInCopy = CreateObject("InCopy.Application")
Set myFileSystemObject = CreateObject("Scripting.FileSystemObject")
Rem You'll need to fill in a valid file path for your system.
Set myTextFile = myFileSystemObject.CreateTextFile("c:\scriptmenuactionnames.txt",
True, False)
For myCounter = 1 To myInCopy.ScriptMenuActions.Count
Set myScriptMenuAction = myInCopy.ScriptMenuActions.Item(myMenuCounter) myTextFile.WriteLine myScriptMenuAction.Name
Next myTextFile.Close
ScriptMenuAction
also can run scripts during their beforeDisplay Event
, in which case they are executed before an internal request for the state of the
ScriptMenuAction
(for example, when the menu
Menus Working with script menu actions 77 item is about to be displayed). Among other things, the script can then change the menu names and/or set the enabled/checked status.
In the following sample script, we add an
EventListener
to the beforeDisplay Event
that checks the current selection. If there is no selection, the script in the EventListener disables the menu item. If an item is selected, the menu item is enabled, and choosing the menu item displays the type of the first item in the selection. (For the complete script, see BeforeDisplay.)
Set myInCopy = CreateObject("InCopy.Application")
Set mySampleScriptAction = myInCopy.ScriptMenuActions.Add("Display Message")
Set myEventListener = mySampleScriptAction.EventListeners.Add("onInvoke",
"c:\WhatIsSelected.vbs ")
Set mySampleScriptMenu = myInCopy.Menus.Item("$ID/Main").Submenus.Add("Script Menu
Action")
Set mySampleScriptMenuItem = mySampleScriptMenu.MenuItems.Add(mySampleScriptAction) mySampleScriptMenu.EventListeners.Add "beforeDisplay", "c:\BeforeDisplayHandler.vbs"
The BeforeDisplayHander tutorial script file contains the following script:
Set myInCopy = CreateObject("InCopy.Application")
Set mySampleScriptAction = myInCopy.ScriptMenuActions.Item("Display Message")
If myInCopy.Selection.Count > 0 Then mySampleScriptAction.Enabled = True
Else mySampleScriptAction.Enabled = False
End If
The WhatIsSelected tutorial script file contains the following script:
Set myInCopy = CreateObject("InCopy.Application") myString = TypeName(myInCopy.Selection.Item(1))
MsgBox "The first item in the selection is a " & myString & "."
advertisement
Key Features
- Seamless collaboration between copywriters and designers
- Copyflow workspace tailored for editorial workflows
- Effortless integration with InDesign for copy placement and editing
- Comprehensive text editing and styling capabilities
- Efficient handling of long-form and complex documents
- Streamlined copyfitting and typesetting features
- Advanced typography controls for precise text formatting
Related manuals
Frequently Answers and Questions
Can InCopy be used independently of InDesign?
How does InCopy integrate with InDesign?
What are the benefits of using InCopy for editorial workflows?
Does InCopy support advanced typography features?
advertisement
Table of contents
- 7 Introduction
- 7 How to use the scripts in this document
- 7 About the structure of the scripts
- 8 For more information
- 8 About InCopy
- 8 Relationships between InCopy and InDesign files
- 8 Stories
- 9 Page geometry
- 9 Metadata
- 9 The document model
- 10 User-interface differences
- 10 Design and architecture
- 11 Getting Started
- 11 Installing scripts
- 12 Running scripts
- 12 Using the scripts panel
- 12 VBScript language details
- 13 Using the scripts in this document
- 13 Your first InCopy script
- 14 Walking through the script
- 14 Scripting terminology and the InCopy object model
- 14 Scripting terminology
- 17 Understanding the InDesign and InCopy object model
- 23 Measurements and positioning
- 24 Adding features to “Hello World
- 26 Scripting Features
- 26 Script preferences
- 27 Getting the current script
- 27 Script versioning
- 28 Targeting
- 28 Compilation
- 28 Interpretation
- 29 Using the DoScript method
- 29 Sending parameters to DoScript
- 29 Returning values from DoScript
- 30 Running scripts at start-up
- 31 Text and Type
- 31 Entering and importing text
- 31 Stories and text frames
- 31 Adding text to a story
- 32 Replacing text
- 32 Inserting special characters
- 33 Placing text and setting text-import preferences
- 37 Exporting text and setting text-export preferences
- 40 Text objects
- 41 Selections
- 42 Moving and copying text
- 43 Text objects and iteration
- 44 Formatting text
- 44 Setting text defaults
- 47 Fonts
- 48 Applying a font
- 48 Changing text properties
- 49 Changing text color
- 50 Creating and applying styles
- 51 Deleting a style
- 52 Importing paragraph and character styles
- 52 Finding and changing text
- 52 Find/change preferences
- 53 Finding text
- 54 Finding and changing formatting
- 55 Using grep
- 57 Using glyph search
- 57 Tables
- 60 Autocorrect
- 61 Footnotes
- 62 User Interfaces
- 62 Dialog-box overview
- 64 Your first InCopy dialog box
- 64 Adding a user interface to “Hello World
- 65 Creating a more complex user interface
- 67 Working with ScriptUI
- 68 Creating a progress bar with ScriptUI
- 68 Creating a button-bar panel with ScriptUI
- 71 Menus
- 71 Understanding the menu model
- 73 Localization and menu names
- 74 Running a menu action from a script
- 74 Adding menus and menu items
- 75 Menus and events
- 76 Working with script menu actions
- 78 Events
- 78 Understanding the event scripting model
- 80 About event properties and event propagation
- 81 Working with eventListeners
- 83 A sample “afterNew” eventListener
- 85 Notes
- 85 Entering and importing a note
- 85 Adding a note to a story
- 85 Replacing text of a note
- 86 Converting between notes and text
- 86 Converting a note to text
- 86 Converting text to a note
- 86 Expanding and collapsing notes
- 86 Collapsing a note
- 86 Expanding a note
- 87 Removing a note
- 87 Navigating among notes
- 87 Going to the first note in a story
- 87 Going to the next note in a story
- 87 Going to the previous note in a story
- 88 Going to the last note in a story
- 89 Tracking Changes
- 89 Navigating tracked changes
- 90 Accepting and reject tracked changes
- 90 Information about tracked changes
- 91 Preferences for tracking changes
- 94 Assignments
- 94 Assignment object
- 94 Opening assignment files
- 94 Iterating through assignment properties
- 95 Assignment packages
- 95 An assignment story
- 95 Assigned-story object
- 95 Iterating through the assigned-story properties
- 97 Overview
- 97 The best approach to scripting XML in InCopy
- 98 Scripting XML Elements
- 98 Setting XML preferences
- 98 Setting XML import preferences
- 99 Importing XML
- 99 Creating an XML tag
- 100 Loading XML tags
- 100 Saving XML tags
- 100 Creating an XML element
- 100 Moving an XML element
- 100 Deleting an XML element
- 101 Duplicating an XML element
- 101 Removing items from the XML structure
- 101 Creating an XML comment
- 101 Creating an XML processing instruction
- 102 Working with XML attributes
- 102 Working with XML stories
- 103 Exporting XML
- 103 Adding XML elements to a story
- 103 Associating XML elements with text
- 105 Applying styles to XML elements
- 106 Working with XML tables