Skip to main content
jduncan
Community Expert
Community Expert
July 29, 2022
Answered

Ai Command Palette

  • July 29, 2022
  • 9 replies
  • 11515 views

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.

 

 

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).

 

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

 

Notes:
⚠️ 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).

 

⚠️ 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

This topic has been closed for replies.
Correct answer jduncan

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! 🍻

 

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

9 replies

m1b
Community Expert
Community Expert
January 20, 2023

Hi @jduncan, I'm very late to see this post, but wanted to let you know that this is a brilliant idea! Thanks so much for building and sharing it. I'm going to try it out. I'm a fan of the "command palette" idea in general and actually currently use Paletro.app on MacOS for launching Illustrator scripts from within Illustrator. I think Ai Command Palette will be more flexible though.

- Mark

jduncan
Community Expert
jduncanCommunity ExpertAuthor
Community Expert
January 20, 2023

Hey @m1b, thanks for the kind words! Ai Command Palette was kind of "birthed" from a system I built in Alfred.app that allowed me to fire scripts and some menu commands (probably very similar to what you created with Paletro.app). The base script has since turned into a much larger beast but it's something I use every day, so the dev time was certainly worth it. Hopefully, it can save a few people a lot of mouse clicks 🤞. Cheers!

jduncan
Community Expert
jduncanCommunity ExpertAuthorCorrect answer
Community Expert
October 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! 🍻

 

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

jduncan
Community Expert
jduncanCommunity ExpertAuthor
Community Expert
September 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 🍻

 

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.
rcraighead
Legend
August 17, 2022

Amazing work! Thank you.

Participant
August 4, 2022

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:

 

 

 

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?

Participant
August 4, 2022

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.

Participating Frequently
August 10, 2022

*ExtendScript API not APO...


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?

Kurt Gold
Community Expert
Community Expert
August 1, 2022

Josh, I just posted a localised version of the Command palette for German versions of Illustrator.

 

You may want to take a look at it.

 

Command Palette – Localised version (German)

 

jduncan
Community Expert
jduncanCommunity ExpertAuthor
Community Expert
August 1, 2022

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

jduncan
Community Expert
jduncanCommunity ExpertAuthor
Community Expert
August 3, 2022

@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!

Inspiring
July 30, 2022

Hi @jduncan 

How to run it? I put it in the script folder and executed it from the menu file > script , but it didn't show any prompts or windows....

femkeblanco
Legend
July 30, 2022

@Raymond ZJH  You should be able to run it as any other script.  There is no special requirement. 

 

@jduncan  Very nice.  Thanks for sharing. 

Inspiring
August 1, 2022

Hi @femkeblanco @jduncan 

 

I'm facing a major problem: The scripts don't get executed when clicking it from menu file > script, Nothing happens at all.

 

Do you perhaps have an idea what I may be overlooking?

 

Sergey Osokin
Inspiring
July 30, 2022

It looks great. You take the trouble to move all the commands and think about the UI 👍

Kurt Gold
Community Expert
Community Expert
July 29, 2022

Thanks for providing that approach, jduncan.

 

I will try it next week.

 

Probably not really comparable, but it's a bit like Illustrator's native Discover panel (which is pretty new), right?

 

https://helpx.adobe.com/illustrator/using/illustrator-discover.html

 

jduncan
Community Expert
jduncanCommunity ExpertAuthor
Community Expert
July 29, 2022

Yeah, I'm not a big fan of the new discover/help panel (somewhat slow and the results can be blah). I'm a heavy user of the Alfred app on Mac so I wanted something similar that was super fast and efficient. I first built this to only access menu commands but then I realized I could chain them together which is a complete game changer (at least for me).

 

Thanks for checking it out!

CarlosCanto
Community Expert
Community Expert
July 29, 2022

jduncan this script is AMAZING!! what a great idea.

 

thanks for developing and sharing with the community!