Jump to content

Update Existing CTOC in FrameMaker


Doug
 Share

Recommended Posts

This code lets you auto-update the chapter TOCs in your Adobe FrameMaker documents. There is some minimal problem condition-anticipating code, but it's a fairly dumb script. You must have only one document open in FrameMaker, or if you have more than one open, they must all be minimized. If there is more than one Frame doc open and not minimized, the script it likely to malfunction.

I welcome suggestions for improvement, if anyone has ideas. I spent about six hours hashing out this, my first AutoIT script. I swiped and modified some code from Slim Shady to house my code in a GUI window (thanks, Slim).

--Doug

;====================================================

;================= Example of a GUI =================

;====================================================

; AutoIt version: 3.0.103

; Language: English

; Author: "SlimShady" (GUI window)

; Doug Bailey (CTOC update script)

;

; ----------------------------------------------------------------------------

; Script Start

; ----------------------------------------------------------------------------

;Include constants

#include <GUIConstants.au3>

;Initialize variables

Global $GUIWidth

Global $GUIHeight

;Initialize flag for While loop

Global $WFlag

$WFlag = 1

$GUIWidth = 180

$GUIHeight = 40

;Create window

GUICreate("Update CTOCs", $GUIWidth, $GUIHeight)

;Create an edit box with no text in it

;$Edit_1 = GUICtrlCreateEdit("", 50, 50, 20, 10)

;Create an "OK" button

$OK_Btn = GUICtrlCreateButton("Update", 22, 10, 70, 25)

;Create a "CANCEL" button

$Cancel_Btn = GUICtrlCreateButton("Exit", 97, 10, 60, 25)

;Show window/Make the window visible

GUISetState(@SW_SHOW)

;Loop until:

;- user presses Esc

;- user presses Alt+F4

;- user clicks the close button

While $WFlag

;Pause a bit so the script doesn't use alot of CPU time

Sleep(25)

;After every loop check if the user clicked something in the GUI window

$msg = GUIGetMsg()

Select

;Check if user clicked on the close button

Case $msg = $GUI_EVENT_CLOSE

;Destroy the GUI including the controls

GUIDelete()

;Exit the script

Exit

;Check if user clicked on the "OK" button

Case $msg = $OK_Btn

;MsgBox(64, "New GUI", "You clicked on the OK button!")

; Wait for FrameMaker to receive focus, then create new CTOC

WinActivate ("Adobe FrameMaker")

MouseUp("left")

MouseUp("right")

Send ("{LEFT}")

Send ("{ALTDOWN}Sb")

Send ("{ALTUP}")

Send ("{ENTER}")

Send ("{ALT}C")

Send ("{ENTER}")

; Save and close CTOC; focus returns to the parent document

Sleep(150)

Send ("^s")

Sleep(150)

Send ("^W")

; Select the CTOC by selecting the entire text flow

Sleep(150)

Send ("^F")

Send(" ")

Sleep(150)

Send ("^A")

; Update the text inset CTOC

Sleep(80)

Send ("{ALTDOWN}Eiu")

Send ("{ALTUP}")

Sleep(150)

Send ("^s")

WinActivate ("Update CTOCs")

;Check if user clicked on the "CANCEL" button

Case $msg = $Cancel_Btn

$WFlag = 0

EndSelect

WEnd

;====================================================

;=== End Script ===

;====================================================

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...