Script To Deselect Invert Within Color Range

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

MoreBeer
Posts: 6
Joined: Wed Jul 07, 2021 1:18 pm

Script To Deselect Invert Within Color Range

Post by MoreBeer »

Have been trying to get a script to work just to deselect the Invert Checkbox within Color Range if it was selected previously and can't get it to work?

In the sample below I would assume changing IdInvr to false would do it, although it doesn't? Any help is immensely appreciated!

Been a member here from way back under the name Colorguy but couldn't remember my login details, so I made a new account.

Edit Added: The script below does work in Photoshop versions up to CS6, although does not work in Creative Cloud.


var idClrR = charIDToTypeID( "ClrR" );
var desc18 = new ActionDescriptor();
var idClrs = charIDToTypeID( "Clrs" );
var idClrs = charIDToTypeID( "Clrs" );
var idMdtn = charIDToTypeID( "Mdtn" );
desc18.putEnumerated( idClrs, idClrs, idMdtn );
var idmidtonesFuzziness = stringIDToTypeID( "midtonesFuzziness" );
desc18.putInteger( idmidtonesFuzziness, 40 );
var idmidtonesLowerLimit = stringIDToTypeID( "midtonesLowerLimit" );
desc18.putInteger( idmidtonesLowerLimit, 105 );
var idmidtonesUpperLimit = stringIDToTypeID( "midtonesUpperLimit" );
desc18.putInteger( idmidtonesUpperLimit, 150 );
var idInvr = charIDToTypeID( "Invr" );
desc18.putBoolean( idInvr, false );
var idcolorModel = stringIDToTypeID( "colorModel" );
desc18.putInteger( idcolorModel, 0 );
executeAction( idClrR, desc18, DialogModes.NO );
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Script To Deselect Invert Within Color Range

Post by Kukurykus »

I manually checked the invert button and applied changes. Then I deselcted selection and used your code. It selected uninverted area. It works.
MoreBeer
Posts: 6
Joined: Wed Jul 07, 2021 1:18 pm

Re: Script To Deselect Invert Within Color Range

Post by MoreBeer »

Thanks for the reply! It doesn't work here. Only in PS CS6 and under it does. In any CC version it doesn't. If that invert checkbox was selected previously and the script is run, it doesn't deselect invert. I even tried creating a Color Range settings file with invert deselected and saving it. Then incorporating loading that settings file into a new script. No dice. Although the settings file when loaded does change invert if done manually through color range, but not through an automated process such as a script or action. I'll make a short video and post a link to it this week. Once again, thank you for responding!
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Script To Deselect Invert Within Color Range

Post by Kukurykus »

Okey post it. btw I'm in 22.4.2 Release, and you? Maybe reset Photoshp preferences to default?
MoreBeer
Posts: 6
Joined: Wed Jul 07, 2021 1:18 pm

Re: Script To Deselect Invert Within Color Range

Post by MoreBeer »

I tested CC 2017 2018 on Mac and 2017 Windows. Will test 2020 2021 tomorrow on both. Will post video of this script and another with a preset loading through script and action. Thank you again!
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Script To Deselect Invert Within Color Range

Post by Kukurykus »

I know there was a problem after CS6 in CC with it, but if now it works for me then probably it was lately fixed.
MoreBeer
Posts: 6
Joined: Wed Jul 07, 2021 1:18 pm

Re: Script To Deselect Invert Within Color Range

Post by MoreBeer »

I tested the script along with other scripts I put together today on the latest version of Photoshop and none of them deselect the invert checkbox as pictured below. After running that script or a similar script, including a script that loads a specific color range settings file with Invert deselected, the invert box is not deselected if accessing Color Range thereafter.

It does work on CS6 and below although not on any CC release. The desired outcome is for the script or action to deselect that checkbox if/when color range is accessed again by either an action, script or automation plugin, which is doesn't? Some guy years ago on Adobe's site who claimed to be an expert (who knows?) says this isn't possible to do with a script although I can't see why not?
Attachments
invert-checkbox.jpg
invert-checkbox.jpg (27.65 KiB) Viewed 3274 times
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Script To Deselect Invert Within Color Range

Post by Kukurykus »

It remembers checking that by hand. If you open it and check it on, then open again it is on. When by script with DialogModes.ALL you check it on then it is remembered as well, so opening it manually it will be already on. The same is when you check it off. Doing that by action or script with DialogModes.NO resets it but only for action / script performance. To reset it to default you have probably reset all your preferences.

Script To Deselect Invert Within Color Range - Photoshop
MoreBeer
Posts: 6
Joined: Wed Jul 07, 2021 1:18 pm

Re: Script To Deselect Invert Within Color Range

Post by MoreBeer »

Thanks for the reply. This change in how the UI in Photoshop behaves started with CC. Prior to then, a script or plugin function to turn color range invert off resulted in it off....period, if manually accessing color range or through an automated process following once it was forced off, it remained off unless changed. Have been struggling with this one for years.

I had a call to force invert OFF as a function of several automation plugins I've developed over the years. With the emergence of CC, this forced call doesn't work either. It also makes sense that loading a color range settings file per specification through an automated process would work, but no. I'll get around this somehow and will post a solution although likely not of too much interest to others. Once again, thank you very much for responding. I do appreciate it.
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Script To Deselect Invert Within Color Range

Post by Kukurykus »

What the link to your plugins website?