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)
@sharkcellar
Copy link

Does this work with the most recent version of PS? I can't seem to get it to work.

@bencanfield
Copy link

bencanfield commented Oct 15, 2021

Does this work with the most recent version of PS? I can't seem to get it to work.

Same here.. not sure what to do after going to File > Scripts > Browse, and selecting the file. If I try it again it says it's already installed, but I don't see anything.

Edit: I had to go to File > Scripts > Scripts Event Manager and check the box to "Enable Scripts to Run Scripts/Actions" for it to work.

@kumicat
Copy link

kumicat commented Jan 31, 2022

I cant get this to work. I get this message when I try to use the tool even though both files are in the scripts folder. i tried @bencanfield 's suggestion but it did nothing :(
image

@roguesleipnir
Copy link
Author

roguesleipnir commented Apr 24, 2022

Sorry for the very late reply, everyone.
I found the issue with the file paths that might be happening with other versions of photoshop.

I update the scripts, but it now requires you to create a new folder (PluginLasso) in your Photoshop folder so it will be sure to reference it.

@Krimson-Knuckles
Copy link

Krimson-Knuckles commented Jun 18, 2022

image
I am getting this message prompt, Cannot get it to work.......... Help !!
Edit : I named my folder 'PluginsLasso' which is incorrect it should be 'PluginLasso' No 's'
In the instructions in some parts there are typo.... nvm, It works now !
and Huge Props to Ryan/rouguesleipnir for helping me out (I reached him out on his instagram).

@Dastan79
Copy link

Thank you so much all works

@Dat1k
Copy link

Dat1k commented Mar 5, 2024

image
Hello Sir, it doesn't work for me at all. My version of Photoshop is 2023. AFter i make Lasso there is that window appears, How to fix it ?

@chichi233
Copy link

love!! thank you over much !!!!!!!!!!!!!

@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