CREATING A KEYBOARD SHORTCUT

In this week’s blog post we take a step backward to review creating a keyboard shortcut to launch a script.

If you want to follow along with this post you will want the script that we created in our previous blog post: Web Document from Preset. You can get the script from our Feature page. If you don’t want to download the script, you can use the code below that is a cutdown version. This script does no more than create a web document from a document preset that has web intent (no added automation; no custom dialog.)

Web Doc From Preset_Simple

--assumes a preset having web intent exists
set userPrompt to "Choose Preset for creating a web document"
tell application "Adobe InDesign CC 2018"
   set presetList to name of document presets where intent is web intent
   try
	set userChoice to my getChoice(presetList, userPrompt)
	set docRef to make document with properties {document preset:userChoice}
   on error errStr
	activate
	display alert ("Error: " & errStr)
   end try
end tell
userChoice

on getChoice(choiceList, userPrompt)
   set userChoice to choose from list choiceList with prompt userPrompt
   if userChoice = false then
	error "User Cancelled"
   else
	return item 1 of userChoice
   end if
end getChoice

PUT YOUR SCRIPT TO WORK

Now that you have a script, put it to work using a keyboard shortcut. The steps for this will be as follows:

  • Place the script in one of InDesign’s predetermined script library folders
  • Create a Keyboard Shortcut to launch the script
  • Launch the Script using the Keyboard Shortcut

Script Library Folders

InDesign has two locations for saving scripts, the Application folder and the User’s folder. To see where these folders are located:

  1. Open the Scripts Panel
    If the Scripts panel is not listed in the panel listing to the right of your window, open it from the Window menu (Window > Utilities > Scripts)

…Scripts panel with folders for scripts

Get the Path to the Folder
Control-Click (Right-Click) on the Application folder listing and select Reveal in Finder to see the path to the folder. (You will want to have Finder’s folder display in columnar view.)

…Click Reveal in Finder to see path to selected item

The path to the Application scripts folder is inside InDesign’s Application folder (Finder’s columnar view).

…Path to the Appiication’s scripts folder

    1. Try the same with the User folder listing.
      You will see that the path to this folder is pretty complex and starts with the user’s Library folder.
    2. Add your script to the folder desired (we will use the User folder).
      The good news is that once you have revealed the folder in the Finder, you can simply click on the script to add and drag it into the folder.

    Set Up a Keyboard Shortcut

    The Keyboard Shortcut dialog is opened from InDesign’s Edit menu.

…the Keyboard Shortcut dialog

  1. Create a Shortcut Set for your Scripts
    If you don’t have a set established for your scripts, select Scripts from under the Product Area dropdown and click on the New Set button.
  2. Name your Shortcut set.
    In the Set field, enter a name for your set (maybe MyScripts).
  3. Select your Script
    From the Commands list scroll down to select your script from the appropriate folder listing (Application or User). You should see the script you added from above.
  4. Click on the listing for the script you added
  5. Add Shortcut
    In the New Shortcut field, add the keyboard shortcut you want to assign to the script. You will find the Option+Shift + key combination is not already overused by the application.
    If a keyboard shortcut has already been assigned, this will be reported as it has in the following screenshot (for the Command + G shortcut). 

..Warning appears if shortcut is already assigned

  1. For my preference, I would give the script (to create a web document from a preset) the option + shift + W shortcut to associate “W” with “Web”.
  2. Assign Context in which the script will run
    You will most likely want to keep most of your scripts available for the Default Context mode.
  3. Assign the Shortcut
    Once you have entered a keyboard shortcut that is not already assigned, click the Assign button to assign the shortcut to the script.
  4. Click OK
    You can assign any number of shortcuts to scripts before clicking the OK button. As you have no other scripts to assign, click the OK button.

Launch the Script

Back in InDesign, if you reopen the Scripts panel, you should see the keyboard shortcut you have assigned to the script as part of its listing.

Now that you have assigned a shortcut to the script, try it out. Make sure InDesign is frontmost and enter the keyboard shortcut.

Your new document will be created. You are now ready to complete your masterpiece. If you used our Feature page script you can also take advantage of the layers that were created and the styles you imported. Layers can be used to organize your document, and the styles selected for import will be ready to use possibly with little or no modification.

UPWARD AND ONWARD

In the next blog post we will look at creating stylesheets, along with some of the ways they can be used to make document creation even more automated.

Disclaimer

Scripts are provided for demonstration and educational purposes. No representation is made to their accuracy or completeness. Readers are advised to use the scripts at their own discretion.