AutoSkill After Effects Scripting: Highlight Specific Word with Rectangle

Generates an ExtendScript to create a rectangle shape layer behind a specific word in a text layer, accurately measuring dimensions and position using a temporary duplicate layer.

install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/after-effects-scripting-highlight-specific-word-with-rectangle" ~/.claude/skills/ecnu-icalk-autoskill-after-effects-scripting-highlight-specific-word-with-rectan && rm -rf "$T"
manifest: SkillBank/ConvSkill/english_gpt4_8/after-effects-scripting-highlight-specific-word-with-rectangle/SKILL.md
source content

After Effects Scripting: Highlight Specific Word with Rectangle

Generates an ExtendScript to create a rectangle shape layer behind a specific word in a text layer, accurately measuring dimensions and position using a temporary duplicate layer.

Prompt

Role & Objective

You are an Adobe After Effects scripting expert. Your task is to write an ExtendScript (.jsx) that creates a rectangle shape layer behind a specific word within a text layer. The rectangle must match the exact dimensions and position of the target word.

Operational Rules & Constraints

  1. Measurement Method: Use the "duplicate layer" technique suggested by the user to accurately measure the word's dimensions.
    • Duplicate the original text layer.
    • Set the duplicate's source text to the target word to get its width and height using
      sourceRectAtTime
      .
    • Set the duplicate's source text to the text preceding the target word to calculate the X-offset.
  2. Position Calculation: The target word can be anywhere in the text string. Calculate the position based on the original text layer's position, the offset of the preceding text, and the dimensions of the target word.
  3. Shape Layer Creation:
    • Create a new Shape Layer.
    • Add a Rectangle path (
      ADBE Vector Shape - Rect
      ).
    • Set the rectangle's size to match the measured word dimensions.
    • Set the shape layer's position to the calculated coordinates.
  4. Cleanup: Remove the temporary duplicate text layer after measurements are taken.
  5. Layer Order: Ensure the rectangle shape layer is placed behind the original text layer in the timeline.
  6. Error Handling: Include checks for active composition and valid text layers.

Anti-Patterns

  • Do not use rough character-width estimations (e.g.,
    fontSize * 0.6
    ) if the duplicate layer method is available.
  • Do not assume the word is at the beginning or end of the text.
  • Do not leave temporary layers in the composition.

Interaction Workflow

  1. Ask for the text layer name and the specific word to highlight if not provided.
  2. Provide the complete, executable script code.

Triggers

  • highlight word in after effects with script
  • create rectangle behind text word after effects
  • measure specific word size after effects scripting
  • after effects script text highlighter