Skip to content

Instantly share code, notes, and snippets.

@roguesleipnir
Last active February 17, 2025 14:45
Show Gist options
  • Save roguesleipnir/4eea27ecada2e2cc11375a92d4571bd9 to your computer and use it in GitHub Desktop.
Save roguesleipnir/4eea27ecada2e2cc11375a92d4571bd9 to your computer and use it in GitHub Desktop.
Auto-Fill Lasso Scripts for Photoshop.

Auto-Fill Lasso Scripts for Photoshop.

Devlog post on https://roguesleipnir.wordpress.com/2020/05/29/hacking-art-my-photoshop-lasso-auto-fill-script/ Ko-fi shop at https://ko-fi.com/s/0ad1accdd3

Installation

  • Download ZIP link is at the top-right of this page.

  • Extract the contents into a new folder called PluginLasso.

  • Move the new PluginLasso folder to the same folder as your Photoshop Executable (Photoshop.exe).

  • This is to avoid path conflicts with the folders on different Photoshop versions.

  • Run with File > Scripts > Browse…

  • Your Photoshop folder > PluginLasso > LassoAutoFillSetup.jsx.

  • Activate/Deactivate event in File > Scripts > Script Event Manager... > Enable Events to Run Scripts/Actions > Done.

Usage

  • Make sure the Tool is set to New Selection only, not other modes.
  • Selection tools like Lasso, Marquee will auto-fill with the foreground color.
  • Holding Shift while during a selection will cause auto-delete instead of auto-fill.
  • Holding Ctrl while ending a selection will revert back to selection instead of fill/delete.
  • This also prevents the Ctrl+A shortcut from filling everything.
  • Feather selection options still work, use it to make gradients and blurred shapes.

Creating the Toggle Action

  • In the Actions Panel (Window > Actions) (Alt + F9)
  • Actions Panel > Click the New Action button
  • Go to File > File > Scripts > Script Event Manager > Done
  • Actions Panel > Click the Stop Recording button
  • Double Click the newly created Action
  • Rename it and Add a Function Key shortcut.
  • This will open the Script Manager popup faster to enable/disable the lasso event.

https://ko-fi.com/sleipnir https://www.instagram.com/roguesleipnir/

Testing

try {
// If bounds are null then there is no selection.
// But null check fails? So use Try/Catch instead.
if (app.activeDocument.selection.bounds) {
// Check Shift Modifier
SHIFT = ScriptUI.environment.keyboardState.shiftKey;
CTRL = ScriptUI.environment.keyboardState.ctrlKey;
// Fill manually.
if (!(CTRL || SHIFT)) {
app.activeDocument.selection.fill(app.foregroundColor);
app.activeDocument.selection.deselect();
// Can be used to play another action like "LassoShapes/LassoFill".
// 'ActionSet/ActionId'
// var actionExec = charIDToTypeID( "Ply " );
// var descriptor = new ActionDescriptor();
// var idNull = charIDToTypeID( "null" );
// var actionRef = new ActionReference();
// var actionId = charIDToTypeID( "Actn" );
// actionRef.putName( actionId, "LassoFill" );
// var idActionSet = charIDToTypeID( "ASet" );
// actionRef.putName( idActionSet, "LassoShapes" );
// descriptor.putReference( idNull, actionRef );
// executeAction( actionExec, descriptor, DialogModes.NO );
}
else if (SHIFT) {
var idDlt = charIDToTypeID( "Dlt " );
executeAction( idDlt, undefined, DialogModes.NO );
app.activeDocument.selection.deselect();
}
}
}
catch (exception) {
}
// Copy the scripts from the Photoshop folder
// To avoid any problems with the Plugins path per Photoshop version,
// create your own folder to reference here,
// on the same folder as your Photoshop Executable file (Photoshop.exe)
var eventFile = new File(app.path + "/PluginLasso/LassoAutoFillAction.jsx")
// Add the notifier to the Script Event Manager.
// Apparently this doesn't work when done from the window because of a bug.
// You need to add the 'setd' event through this code.
app.notifiers.add("setd", eventFile)
@hsijenliu
Copy link

The de-selection function seems to be disabled in PS 2025(the latest one atm), and holding Ctrl while ending a selection, which used to revert back to selection instead of filling or deleting, also doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment