Photoshop with 4-button tablet: Fine control, multiple buttons



Original question - solution below

_Hey there, _ _as you can see, I'm new. :) I love KM already, but I've run into something where I am kinda stuck, so I thought I'd ask. My workflows are attached._

Use case: I’m drawing in photoshop with a Wacom Bamboo with four hotkeys and a pen. I have the option modifier bound on the pen. However, four buttons aren’t enough, so I’ve double-bound them - they do something whether I use opt, and they also use a switch (for example, switch between brush and eraser on keypress).

However, I find myself in need of yet another distinction :smiley: Basically, I want to switch between brush and eraser, however, if I am on a layer mask, I would like the same button to swap foreground- and background-colour.

Can I somehow find out whether Photoshop is on a layer mask?

Thanks for your help already!


The key are application groups! I’ve simply duplicated my macros:
regular macro group
Layer mask macro group

Here is the final collection of macros: (dropbox)

What it now does:
All buttons are mapped double, once with and once without OPTION.

Without Option:
Button 1 toggles between brush and lasso.
Button 2 sends > (my shortcut for “increase brush size”.
Button 3 sends < (my shortcut for “decrease brush size”.
Button 4 toggles between brush and lasso.

With Option:
Button 1 sends CMD+Z (undo)
Button 2 and 3 send CMD+D (deselect)
Button 4 sends CMD+F (reapply last filter)

The macros for the tools will try to open pngs in preview and move them to the lower-right corner of the screen. You find these (and the corresponding AppleScript) here:

Will look like this:
Alt text

___ ___

Solution 2 (outdated)

This is the script I came up with. Any less hack-ish solution didn’t work.

Button 4.kmmacros (7.8 KB)

tell application "System Events"
	tell process "Photoshop CC"
		set theWindows to windows
		repeat with theWindow in theWindows
			set r1 to properties of theWindow
			set window_name to title of r1
			if (window_name contains "Layer Mask") then
				return 1
			end if
		end repeat
	end tell
end tell
return 0


Hey manavortex,
I am new here myself, but I’ll give it a try.

You should be able to use this applescript to get the name of the front window, in Photoshop that in return should contain the words Layer Mask if the layer mask is currently active:

activate application "Adobe Photoshop CS6"
tell application "System Events"
    tell process "Photoshop"
        get name of window 1
    end tell
end tell

(replace by your specific version of Photoshop of course)

And the window name could be used in a macro like this, to check if a layer mask is active or not and act accordingly:

Detect Photoshop Layer Mask.kmmacros (3.8 KB)

Hope this helps to solve your problem.



Hey trych,
awesome! That sounds exactly what I want! Thanks!


Me again,

okay, after fiddling with this for… too long, I need more help.
I tried your script first, and it doesn’t work the way it is supposed to - it says that window 1 is an invalid index. I’ve tried a ton of stuff by now, including trying to iterate over the windows by name and getting the name or whatever, but the closest I got is stuff like this:

{minimum value:missing value, orientation:missing value, position:{275, 172}, class:window, role description:“standard window”, accessibility description:missing value, focused:false, title:“Adobe Photoshop CC 2015.sdef”, size:{804, 678}, value:missing value, help:missing value, enabled:missing value, maximum value:missing value, role:“AXWindow”, entire contents:{}, subrole:“AXStandardWindow”, selected:missing value, name:“Adobe Photoshop CC 2015.sdef”, description:“standard window”}

I’ve tried iterating over the layers and checking those for “mask”; but it only has a check for QuickMask mode.
I’m using CC2015, in case.

Can you help me out once more?


Hm, I have no idea, what could be wrong. Is it maybe window 2 instead? I had a plugin open in Photoshop when testing again now, which made my document window window 2, since the plugin had a floating window which was Window 1 now. I can only test Photoshop CS 6 over here, so I don’t know what’s different with CC 2015.

However, how I found about the AppleScript in the first place was by watching this video tutorial about using KM together with UI Browser and then using the test version of UI Browser to figure out the window. Maybe you could also download the test version of UI Browser and figure out which window you need to target in AppleScript with CC2015.


Thank you - I’ll keep fiddling around and post my final solution here. :slight_smile:

Edit: Done.