Working with script menu actions. Adobe InCopy CS6

Add to My manuals
108 Pages

advertisement

Working with script menu actions. Adobe InCopy CS6 | Manualzz

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?
Yes, InCopy can be used as a standalone application for text editing and styling.
How does InCopy integrate with InDesign?
InCopy seamlessly integrates with InDesign, allowing copywriters to place and edit copy within InDesign page layouts.
What are the benefits of using InCopy for editorial workflows?
InCopy provides a specialized copyflow workspace tailored for editorial workflows, ensuring efficient and collaborative copywriting and editing.
Does InCopy support advanced typography features?
Yes, InCopy offers advanced typography controls for precise text formatting, giving you complete control over the appearance of your text.
Download PDF

advertisement

Table of contents