I would like to create a palette of Keyboard Shortcuts to access the color palette below and quickly change colors.
thanks in advance for your time and help
I would like to create a palette of Keyboard Shortcuts to access the color palette below and quickly change colors.
thanks in advance for your time and help
In most apps that support the color palette, Shift-Command-C should bring it forward. If not, you can see if the menu has a Show Colors menu command (as that's what it's called) and assign a shortcut in macOS' Keyboard Shortcuts.
Are you wanting to do something beyond just bringing it forward? Or am I misunderstanding the question? The palette is app-specific, so you can't have it show up in an app that doesn't support it, if that's what you're trying to accomplish.
-rob.
thank you. Yes, I want to go beyond ⇧⌘C and find a way to quickly pick and change colors.
Oh, then that will be a frustrating experience, I fear :). The color palette is a floating window with minimal keyboard features, just for selecting the items at the top and bottom of the window.
Found Image for each color will fail, I think, as they're not distinct enough. But the window itself is pretty distinct, so here's a demo of one way to do it.
Choose Colors.kmmacros (56 KB)
In the Found Image step, you'll need to insert your own version of this image:
Use Shift-Command-Control-4 to drag out the same region of the window, then paste it in the image well in the Found Image step.
I set this up with only three colors, and using a prompt with list, which is probably the worst way possible to do this—because when the prompt appears, the color window vanishes, so the macro has to pause to wait for it to reappear after the selection is made.
But you could use this technique to assign individual colors to keys, or maybe use a floating palette, etc.
There may be many better ways to do this, but this is the only one I could think of—the window isn't AppleScriptable (especially if you want an app-independent solution), and this should work relatively well as Keyboard Maestro can find that image fairly easily.
-rob.
thank you very much. You put me on the right track. I am working on it and will post a follow-up. thanks again very much
one problem is that the size of the color palette can vary. Is there a way to use a resize window action to make it's size standard ? Otherwise nothing works. thanks very much
I would prefer also to use a palette of hotkeys rather than selecting from a list. I would be grateful if you could just give me an indication of how you would go about it.
thank you
also what I have found.
easier to set coordinates using this image only
It can vary? When you say "vary" do you mean it can take one of two sizes, or is there an infinite amount of variability? If it's just two (or three) sizes, there is an easy fix: just search for both sizes, but don't search for the second one if the first one is found.
In any case, the colour palette icon which you are "Finding" has a neat trick, due to its circular symmetry: if you just search for the INNER part of the icon, it will probably still "Find" that image even if the image changes size. I use tricks like this myself, so I'm sure it will work. The real problem is that if the palette changes size, how are your offsets going to continue working?
In other words, just search for this. If the image increases in size, this will very likely still find both sizes, because you are not including the outer edge.
You may have to tinker a little bit with the fuzziness, but I'm confident it will work.
There is a misunderstanding.
Finding the image irrespective of the size of the color palette is not a problem when its size varies. But from the found image the coordinates to move the mouse to choose colors no longer work.
Ideally, I would simply like the color palette to be of standard size and location
Run this in an AppleScript action in your macro:
tell application "System Events"
set theApp to item 1 of (every process whose frontmost is true)
set theWin to item 1 of (every window of theApp whose name is "Colours")
set size of theWin to {400, 500}
end tell
Note that the app with the Colour palette must be frontmost or the window doesn't exist. Set the size
to whatever you want -- the above {400, 500}
is "400 pixels wide, 500 pixels tall".
You could also use set position of theWin to {x,y}
to set the top-left corner of the window prior to resizing, so it's always in the same place.
It does not work, but I'am working on it. I have some ideas. Thanks very much
It works here, at least with Notes and KM.
Make sure you are using the same name/spelling as your window shows -- I didn't spot that yours is "Colors", so you'll need to change line 3 to match.
Thanks, @Nige_S! I knew there was a way to control the size of that window, but my hour of futzing with AppleScript and searching the forum for that code was fruitless.
With the size fixed, it becomes pretty easy to write the macro—in fact, you could use math to do it, I think, based on color name. Just store the offsets in X and Y for the 400x400 (or whatever size you pick) window, then look those up based on the desired color.
As an example, with a 300x400 window, it's 25 pixels horizontally between colors and 100 pixels vertically.
-rob.
Fancy driving this further?
This will get you the list of colour names:
tell application "System Events"
set theApp to item 1 of (every process whose frontmost is true)
set theWin to item 1 of (every window of theApp whose name is "Colours")
return description of every radio button of radio group 1 of splitter group 1 of theWin
end tell
And if you know the names:
set theColour to "Teal"
tell application "System Events"
set theApp to item 1 of (every process whose frontmost is true)
set theWin to item 1 of (every window of theApp whose name is "Colours")
click item 1 of (get every radio button of radio group 1 of splitter group 1 of theWin whose description is theColour)
end tell
No math required, even better! @ronald, this is the way!
-rob.
Here's a very rough proof of concept version using @Nige_S' AppleScript to set the color. Note that it assumes the color selection won't change in every app, which may or may not be true—this one is set to work in TextEdit for demo purposes.
Duplicate any existing macro in the group, set its name to one of the crayon colors (exactly!), change its keyboard shortcut and icon, and you're done—it will appear in the palette.
app-TextEdit Color Setter Macros.kmmacros (102 KB)
I only did a few colors as an example, but this definitely makes it simple to work with colors: Select some text, press Control-D, then type M for Maroon, L for Lavender, etc. Press Control-D again to dismiss the palette.
And today I learned that you can hide a macro from the palette by disabling it, and it will still work (at least if it's a subroutine macro) when called by other macros :).
Each macro is ridiculously simple:
The subroutine is nothing more than the AppleScript that sets the color, adjusted to work with the color as a passed-in variable value.
-rob.
You are right. My apologies. I had not noticed the spelling. Works perfectly. thank you very much
WOW !! I fell of my chair. Incredible. Beautiful. So elegant ! Very imaginative to have used buttons.
I created my own macros (color). All went perfectly except for a little snag. it seems that the drop down list can spontaneously change from Crayons to Apple for example, at which point the macros obviously stop working.
Is there any way to set the drop down list to Crayons in the sub-setColor AppleScript ?
thank you very much
If you use the Crayon icon at the top, it should never change, and the list of colors is the same.
Alternatively, this seems to work to click the pop-up menu and select Crayons, at least in English:
Switch to crayons.kmmacros (3.2 KB)
-rob.
FWIW or anyone who might be looking.
This pertains to TextEdit Only which I use quite a bit.
I only use like 4 main colors for coding.
This applescript is quick and efficient to change the highlighted text to the pre-determined color.
Just chiming in...
activate application "TextEdit"
tell application "System Events" to tell text area 1 of scroll area 1 of window 1 of process "TextEdit" to if exists then
set {x, y} to value of attribute "AXSelectedTextRange"
if x ≤ y then tell application "TextEdit" to set color of document 1's characters x thru y to {0, 0, 65535}
end if
-- blue
great ! thank you very much !