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.
What Can It Do:
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:
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
@colt-ink, 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 feature
...
As always, if anyone has issues or suggestions please reach out. Cheers :clinking_beer_mugs:
Ai Version Functionality Checker:
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
Copy link to clipboard
Copied
Yep, I'm going to take a look at it this evening. Thanks for working on this!
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:
/**
* 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)
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!
Copy link to clipboard
Copied
Thanks, Josh.
I posted a modified version according to your latest adjustments.
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.
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!
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:
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?
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.
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!
Copy link to clipboard
Copied
*ExtendScript API not APO...
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?
Copy link to clipboard
Copied
@colt-ink, 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!
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!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Amazing work! Thank you.
Copy link to clipboard
Copied
As always, if anyone has issues or suggestions please reach out. Cheers :clinking_beer_mugs:
Ai Version Functionality Checker:
Windows OS Flicker Bug issue #8:
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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!