• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Ai Command Palette

Contributor ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

If you have worked with apps like Figma, Alfred, or VS Code you know how great the “command palette” is… Well, I wanted that same functionality in Adobe Illustrator so here's what I've come up with.

 

AiCommandPalette.png

 

What Can It Do:

  • most any Illustrator Menu command
  • any actions from your Actions Palette
  • scripts from anywhere on your filesystem
  • AND you can build custom commands that chain other commands together! 🤯

 

Installation:
I recommend installing this action into your scripts folder, then tying it to a keyboard shortcut using something like Keyboard Maestro (Mac), BetterTouchTool (Mac), or AutoHotkey (Windows).

 

:information: I like to use the keyboard shortcut Command-Shift-P since it is somewhat mnemonic for "palette".

 

Notes:
:warning: Using this command palette requires some basic knowledge of Illustrator. The script doesn't know which commands can or can't be run at the time of execution so tread carefully. Most every action this script executes can be undone by choosing Edit > Undo (from the Edit menu at the top of your screen), or by pressing Command-Z (Mac) or Control+Z (Windows).

 

:warning: MENU COMMANDS: I am aware that not all of the included built-in menu commands work. There are a little over 500 included in this script so I'm not interested in testing them all. If you find one that doesn't work, please file an issue in this repository (learn how here).

 

Credits:

  • Shalako Lee for the list of built-in menu commands and their respective executeMenuCommand() commands.
  • sttk3 for the awesome bit of code that gets all of the currently installed Action Sets and Actions.
  • Peter Kahrel and his amazing ScriptUI for Dummies book.
  • Sergey Osokin for the clever openURL() function.

 

It's far from perfect, but it's cool (at least to me). So, please check it out, take it for a spin, try to break it, and let me know what you think.

 

GitHub Download Link: https://github.com/joshbduncan/AiCommandPalette

YouTube Demo Video: https://www.youtube.com/watch?v=Jhh_Dvfs0ro

TOPICS
Scripting , Tools

Views

1.1K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Contributor , Aug 16, 2022 Aug 16, 2022

@Colt_Storify, thanks for the kind words and I'm glad you got your pref file sorted and everything is working fine now. Raycast is on my list of apps to check out, I'm just such a heavy user of Alfred (lots of custom workflows and scripts) that I'm not sure I would ever commit to making the switch. Alfred is the main reason I created Ai Command Palette, tbh...

 

I also wanted to let you know that I just released version 0.2.0 of Ai Command Palette if you want to check it out. It's got some new fea

...

Likes

Translate

Translate
Contributor , Sep 15, 2022 Sep 15, 2022

Ai Command Palette v0.3.0 has been released

Shoutout to @Sergey Osokin for his idea of the version check functionality and his help to develop a work-a-round for the Window OS Flicker/Flashing bug he described here.

 

As always, if anyone has issues or suggestions please reach out. Cheers :clinking_beer_mugs:

 

Read full CHANGLOG here.

 

Ai Version Functionality Checker:

  • Original idea brought up by Sergey Osokin in issue #6 selectTool
  • Ai Command Palette now checks the current Ai version at startup to det
...

Likes

Translate

Translate
Contributor , Oct 21, 2022 Oct 21, 2022

Ai Command Palette v0.4.0 has been released!

 

This is a complete rebuild of the script. Learn more here. Thanks again to @Sergey Osokin and @Kurt Gold for their continued help! :clinking_beer_mugs:

 

P.S. I'll try and get this updated in the near future once I can figure out the new tools that were added in the latest Ai 2023 27.0 release.

 

Added
- Real-Time Localization
- Handled within the main script file via the ExtendScript `localize()` function.
- Commands are built at run-time for the current sy

...

Likes

Translate

Translate
Contributor ,
Aug 01, 2022 Aug 01, 2022

Copy link to clipboard

Copied

Yep, I'm going to take a look at it this evening. Thanks for working on this!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 02, 2022 Aug 02, 2022

Copy link to clipboard

Copied

@Kurt Gold, I pushed some updates today you might want to checkout.

 

The first update included improvements to the `scoreMatches()` functiom:

  • now using regex to match instead of indexOf
  • not counting repeating words for better scoring
  • simplified sorting function
/**
 * Score array items based on string match with query.
 * @param   {String} q   String to search for withing `arr`
 * @param   {Array}  arr String items to try and match.
 * @returns {Array}      Matching items sorted by score.
 */
function scoreMatches(q, arr) {
  var word;
  var words = [];
  var scores = {};
  var words = q.split(" ");
  for (var i = 0; i < arr.length; i++) {
    var score = 0;
    for (var n = 0; n < words.length; n++) {
      word = words[n];
      if (word != "" && arr[i].match("(?:^|\\s)(" + word + ")", "gi") != null) score++;
    }
    if (score > 0) scores[arr[i]] = score;
  }
  return sortKeysByValue(scores, "score", "name");
}

/**
 * Sort an objects key by their value.
 * @param   {Object} obj Simple object with `key`: `value` pairs.
 * @returns {Array}      Array of sorted keys.
 */
function sortKeysByValue(obj) {
  var sorted = [];
  for (var key in obj) {
    for (var i = 0; i < sorted.length; i++) {
      if (obj[key] > obj[sorted[i]]) break;
    }
    sorted.splice(i, 0, key);
  }
  return sorted;
}

 

The second update was to the actual command palette: (View diff on GitHub)

  • I have some custom functionality that allows you to move the listbox selection up and down while still in the edittext search query field using the up and down arrow keys.
    • One problem with this functionality is that when a listbox listitem is selected via a script the API moves the visible "frame" of items so that the new selection is at the top. This is not standard behavior, and not even how the listbox behaves when you use the up and down keys inside of the actual listbox. So, I updated the functionality to better match the standard behavior.
    • Another problem is if a selection is made inside of the actual listbox frame by the user (via mouse or keyboard) the API doesn't offer any way to know which part of the list is currently visible in the listbox "frame". If the user was to re-enter the `q` edittext and then hit an arrow key the above event listener will not work correctly so I just move the next selection (be it up or down) to the middle of the "frame".

 

As for your localized version, the only thing I noticed not working correctly is the up/down functionality mentioned above. Both the my version and the newly updated version of this functionality expects there to only be 9 visible rows in the listbox. When you increased yours to 15 it breaks this functionality. To see it break, just go to Command Palette Settings > Show All Built-in Commands, and while still in the search query field, keep hitting the down arrow. Once you reach the 9th item in the list, the list will shift down incorrectly. It should shift down until you reach the bottom (or 15 rows in your case). To make this easier to adjust I have included the variable `visibleListItems` that just needs to be updated if you change the listbox size, then all of the functionality would work.

 

If you checkout this diff on GitHub you can see the new parts of `commandPalette()` you would need to implement. It's not a lot (mostly my comments) but it's a better experience for sure. Just make sure to change `visibleListItems` to 15 (or whatever number of rows you have in your listbox).

 

Let me know if any of this makes sense? Cheers!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 03, 2022 Aug 03, 2022

Copy link to clipboard

Copied

Thanks, Josh.

 

I posted a modified version according to your latest adjustments.

 

Kurzbefehle 03

 

By the way, if you like you may take the localised version and store it on your Git repository. This way may be a bit easier to update it.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

I'm working on an 0.2.0 version with some new features so I'll work out how to implement your localized version on Github so we can keep things as similar as possible. Thanks again for your work on this!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

HOLY MOLY

I've been dreaming of a utility like this for the longest time!! You've earned your own folder in my Illustrator directory! Truly appreciate your work here.

I was cruising all day yesterday with this and it was working flawlessly, and then today I opened Illustrator and a receive the error:
Screen Shot 2022-08-04 at 9.46.12 AM.png

 

 

 

Error 21: undefined is not an object.
Line 842
->      data[prop][subProp] = userData[prop]subProp];

 

It does this on both Illustrator 2022 and Illustrator Beta. Illustrator was updated yesterday, while Beta says it was updated 13 days ago. I'm using macOS Monterey v12.5 (M1).

 

Besides the update, the only thing I messed with was to load a bunch of daily-use scripts from the usual suspects (Creold, Ladygin, shspage, Wundes). 

 

My only guess is it's having trouble finding the AiCommandPalette.json? I checked and it's still in the JBD folder under Application Support, so I'm not sure what gives. Any ideas?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Update: I tried removing the AiCommandPalette.json from the JBD folder, and AI Command Palette started working again. I don't remember doing anything to the .json, but I did open it in VS Code just to see how scripts were being referenced.

 

Do you think I did something to break it? I am by no means a coder, so it's possible I bumbled my own way into causing the problem. Or could it be related to something else?

 

Again, a big THANK YOU for creating this. It's a work of art.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Yeah, it's technically not a JSON file. I usually refer to it as "JSON like". It's very similar but when the ExtendScript APO writes the file it puts parens around the JSON. If you do open it in VS Code it will sometimes try to auto format the file and may remove those parens. If they aren't there, ExtendScript can't load the object correctly.

 

I'd just try deleting the JSON file and then reload a few script to make sure it's working again. Let me know if that helps?

 

And thanks for the kind words. I'm glad you are finding it useful! Cheers!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

*ExtendScript API not APO...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 10, 2022 Aug 10, 2022

Copy link to clipboard

Copied

Just a follow-up to not leave anyone (present or future) hanging - it was totally me poking around in VS Code that broke the JSON(-like) file. I deleted it as you suggested and reloaded my scripts, haven't had a single issue since.

I even wrote a simple script for Raycast to give AI Command the shortcut option + space and it's not only replaced like 3 other tools, but saved me so much time and headache.

 

This is great man, amazing stuff. I'd love to give back somehow - any 'buy me a coffee' type thin you use?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 16, 2022 Aug 16, 2022

Copy link to clipboard

Copied

@Colt_Storify, thanks for the kind words and I'm glad you got your pref file sorted and everything is working fine now. Raycast is on my list of apps to check out, I'm just such a heavy user of Alfred (lots of custom workflows and scripts) that I'm not sure I would ever commit to making the switch. Alfred is the main reason I created Ai Command Palette, tbh...

 

I also wanted to let you know that I just released version 0.2.0 of Ai Command Palette if you want to check it out. It's got some new features like tool access, more menu commands, the ability to edit custom commands (workflows), and more. You can see my post about it here, or download it on GitHub here. Please take it for a spin and let me know what you think.

 

Also, I really appreciate you wanting to give back. If that's something you are still interested in, I set up a few "support me" type buttons on my website here. Either way, I'm just glad you are getting use out of my script.

 

Cheers!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

Raycast + Alfred is actually a real dynamic duo depending on the workflow, but I totally get it. The tool is only as good as what you can make with it. That's why it's so exciting to see QoL improvements to Illustrator, which is like the center of my whole professional life. This badboy saves me so much money on antacids every day just by letting me skip over menu trees and get to the actual work.

 

Just pitched in via Stripe - hopefully it puts some gas in the ol code tank. Installing AI Command v2 today! Can't wait!

 

P.S: If it's helpful to other Raycast users, especially non-coders, I thought I'd provide my hacky little python script to launch AiC. If anyone reading this has a smarter way to do it, please do let me know - I am not a coder. The below script will launch AI Command with whichever shortcut you assign it, and it'll launch Illustrator if it's not currently open:

 

 

#!/usr/bin/env python3

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Launch AI Command
# @raycast.mode silent

# Optional parameters:
# @raycast.icon /PATH TO YOUR ICON - EMOJI IS ALSO ACCEPTED
# @raycast.packageName Illustrator

# Documentation:
# @raycast.description Launch AI Command script by Josh Duncan
# @raycast.author Colt Peterson

import os
import subprocess
import sys

# Get the path to the script
script_path = os.path.expanduser("/Applications/YOUR PATH/AiCommandPalette.jsx")

# Check if the script exists
if os.path.exists(script_path):
    # If it does, run the script
    subprocess.call(["osascript", "-e", 'tell application "Adobe Illustrator" to do javascript file "' + script_path + '"'])
else:
    # If it doesn't, prompt the user to locate it
    subprocess.call(["osascript", "-e", 'tell application "Adobe Illustrator" to do javascript file "' + os.path.expanduser("/Applications/SAME PATH AS ABOVE/AiCommandPalette.jsx") + '"'])

 

 

The Icon I use is attached in png and svg, mostly because I thought it was adorable.

Smol tutorial because I remember what it was like not knowing a lick of programming and honestly there isn't much on the web about this:

 

Copy my amateur-hour Python code into a PLAIN text file. Replace the all-caps stuff with your actual file paths. Create a folder somewhere that will forever be your Raycast scripts folder. Save the text file as "launch-ai-command.py" and put it in that folder. Launch Raycast and hit ⌘ + comma to go to preferences. Navigate to Extensions -> Scripts -> Script Commands. Add your scripts folder to Raycast with "Add Directories" in the sidebar. Assign it a hotkey and check 'Enabled'. I use ⌥ + space because AiC is just that common for me. You won't need to access Raycast to use the hotkey, it's always listening for the shortcut.

The final step - and this is important - is to go to joshbduncan.com and send this hero some skrill and/or a thank you note. Sign the note affectionately, don't skimp on the heart emojis. Then, tell somebody who needs development help to hire this clever coder you met on the Adobe forums. Repeat this process for every person on this forum who has ever helped you with script ever. You are now ready to use AI Command Palette with Raycast!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

Icons:

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 16, 2022 Aug 16, 2022

Copy link to clipboard

Copied

Amazing work! Thank you.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 15, 2022 Sep 15, 2022

Copy link to clipboard

Copied

Ai Command Palette v0.3.0 has been released

Shoutout to @Sergey Osokin for his idea of the version check functionality and his help to develop a work-a-round for the Window OS Flicker/Flashing bug he described here.

 

As always, if anyone has issues or suggestions please reach out. Cheers :clinking_beer_mugs:

 

Read full CHANGLOG here.

 

Ai Version Functionality Checker:

  • Original idea brought up by Sergey Osokin in issue #6 selectTool
  • Ai Command Palette now checks the current Ai version at startup to determine which menu commands and tools are compatible with your version of Adobe Illustrator.
    • If your version doesn't meet the minimum version (or maximum version) of a menu command or tool, it will not be available.
    • Any previous workflows that use a menu command or tool will no longer work. You'll be notified of this when you try to run the workflow. You can edit the workflow to remove that menu command or tool.
  • This should allow Ai Command Palette to easily update with the ever-changing Ai menu commands and tools.
  • Any commands/tools can now have properties minVersion and maxVersion.
    • If either are present and your Ai version doesn't meet the requirement Ai Command Palette will remove that functionality at startup.
  • All current min/max versions for menu commands were referenced from the menuCommandString list provided by sttk3.
    • Please note that if the min version listed in the list above was below 17 it was ignored and if the max version was listed at 99 it was also ignored. Ai Command Palette doesn't require a min or max version to be listed for menu commands. All menu commands are executed within a try/catch block so it will fail gracefully and let you know why.
  • Since the app.selectTool() method wasn't introduced until Ai version 24, all tools have that as their min version.

 

Windows OS Flicker Bug issue #8:

  • Very clever solution provided by Sergey Osokin
  • Found that simulating a <TAB> key press via VBScript was the best solution for keeping the user experience the same on Windows and Mac.
  • Only affects Windows users.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 21, 2022 Oct 21, 2022

Copy link to clipboard

Copied

LATEST

Ai Command Palette v0.4.0 has been released!

 

This is a complete rebuild of the script. Learn more here. Thanks again to @Sergey Osokin and @Kurt Gold for their continued help! :clinking_beer_mugs:

 

P.S. I'll try and get this updated in the near future once I can figure out the new tools that were added in the latest Ai 2023 27.0 release.

 

Added
- Real-Time Localization
- Handled within the main script file via the ExtendScript `localize()` function.
- Commands are built at run-time for the current system locale
- New project folder structure
- Common functionality split into separate files/modules for easier development
- Final script is compiled into the single jsx file [AiCommandPalette.jsx](AiCommandPalette.jsx)
- Settings menu only shows certain commands when applicable

 

Changed
- Script was rewritten from the ground up
- Variable names have been changed which will break any settings you have saved on your system
- Settings file has been renamed to make it easy to roll back to a previous version

 

Removed
- Redundant and no longer needed functions
- Excess command data to speed things up

 

Fixed
- Unicode errors for Conté Crayon => Cont\u00E9 Crayon

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines