How to get the foreground/background color in photoshop.

I want to get the foreground or background color at runtime ( by any action ) in photoshop.
What steps should I follow.

For example here is a script I use within Photoshop Actions to save and restore the users foreground and background colors so the action can mess with Photoshops foreground and background colors during its processing.
SaveAndRestoreColors.jsx
/* ======================================================================================
// 2009  John J. McAssey (JJMack)  http://www.mouseprints.net/
// This script is supplied as is. It is provided as freeware.
// The author accepts no liability for any problems arising from its use.
// This script is designed to be used by a Photoshop Action twice
// A good pratice to use when creating an actions that use this scipt is for the action
// not to do a save or play some other action between its two useages of this Script.
// The first time this script is used by an action Photoshops Current Forground
// and Background Colors are saved into the document's meta-data Info Instructions field.
// The second time this script used by the action the script retreives what was
// saved in the meta-data during the first usage and these colors are set.
// and the saved data is removed from the document's meta-data Info Instructions field.
// ===================================================================================== */
<javascriptresource>
<about>$$$/JavaScripts/SaveAndRestoreColors/About=JJMack's SaveAndRestoreColors.^r^rCopyright 2009 Mouseprints.^r^rRun twice script utility for action.^rNOTE:Don't play other actions between runs!^r^rFirst Run records Photoshops foreground and background swatch colors.^rSecond Run restores the recorded colors and removes the recording.</about>
<category>JJMack's Action Run Twice Utility</category>
</javascriptresource>
if (app.documents.length > 0) {
if (app.activeDocument.info.instructions.indexOf("<Colorf>") == -1 ){ // no footprint fisrt useage
//alert("first");
// Retreive Document information for Foot Print
saveforeColor = new SolidColor;
saveforeColor.rgb.red = app.foregroundColor.rgb.red;
saveforeColor.rgb.green = app.foregroundColor.rgb.green;
saveforeColor.rgb.blue = app.foregroundColor.rgb.blue;
savebackColor = new SolidColor;
savebackColor.rgb.red = app.backgroundColor.rgb.red;
savebackColor.rgb.green = app.backgroundColor.rgb.green;
savebackColor.rgb.blue = app.backgroundColor.rgb.blue;
// put footprint in metadata info instructions
app.activeDocument.info.instructions = app.activeDocument.info.instructions + "<Colorf>" + saveforeColor.rgb.red + "," + saveforeColor.rgb.green + "," + saveforeColor.rgb.blue + "</Colorf>" + "<Colorb>" + savebackColor.rgb.red + "," + savebackColor.rgb.green + "," + savebackColor.rgb.blue + "</Colorb>";
//alert( "Saved ="  + "<Colorf>" + saveforeColor.rgb.red + "," + saveforeColor.rgb.green + "," + saveforeColor.rgb.blue + "</Colorf>" + "<Colorb>" + savebackColor.rgb.red + "," + savebackColor.rgb.green + "," + savebackColor.rgb.blue + "</Colorb>");
else {
//alert("second");
// Retreive saved information
colorfOffset = app.activeDocument.info.instructions.indexOf("<Colorf>") + "<Colorf>".length;
colorfLength = app.activeDocument.info.instructions.indexOf("</Colorf") -colorfOffset;
saveforeColor = app.activeDocument.info.instructions.substr(colorfOffset, colorfLength);
colorbOffset = app.activeDocument.info.instructions.indexOf("<Colorb>") + "<Colorb>".length;
colorbLength = app.activeDocument.info.instructions.indexOf("</Colorb") -colorbOffset;
savebackColor = app.activeDocument.info.instructions.substr(colorbOffset, colorbLength);
//alert("Colorf = " + saveforeColor + " Colorb = " + savebackColor );
// Restore Colors
app.foregroundColor.rgb.red = saveforeColor.substr(0,saveforeColor.indexOf(","));
saveforeColor = saveforeColor.substr(saveforeColor.indexOf(",") + 1,saveforeColor.length);
app.foregroundColor.rgb.green = saveforeColor.substr(0,saveforeColor.indexOf(","));
saveforeColor = saveforeColor.substr(saveforeColor.indexOf(",") + 1,saveforeColor.length);
app.foregroundColor.rgb.blue = saveforeColor ;
app.backgroundColor.rgb.red = savebackColor.substr(0,savebackColor.indexOf(","));
savebackColor = savebackColor.substr((savebackColor.indexOf(",") + 1),savebackColor.length);
app.backgroundColor.rgb.green = savebackColor.substr(0,savebackColor.indexOf(","));
savebackColor = savebackColor.substr(savebackColor.indexOf(",") + 1,savebackColor.length);
app.backgroundColor.rgb.blue = savebackColor ;
// Remove footprint from metadata info instructions
before = app.activeDocument.info.instructions.substr(0,app.activeDocument.info.instructions.indexO f("<Colorf>"));
afterOffset = app.activeDocument.info.instructions.indexOf("</Colorb>") + "</Colorb>".length;
after = app.activeDocument.info.instructions.substr(afterOffset, app.activeDocument.info.instructions.length - afterOffset);
//alert ("before = " + before + " after = " + after);
app.activeDocument.info.instructions = before + after;
else { alert("You must have at least one open document to run this script!"); }

Similar Messages

  • What is the purpose of the foreground/background color?

    I want to know what is the purpose of the foreground/background color in photoshop, am knew to PS, so am just trying to figure what are the purposes of some of these stuff.
    Regards,
    Jamaine Semple

    Please read the Help files.  Start with "Creating, Opening and Importing images".
    • Select a canvas color option.
    White Fills the background or first layer with white, the default background color.
    Background Color Fills the background or first layer with the current background color.
    Transparent Makes the first layer transparent, with no color values. The resulting document has a single, transparent layer as its contents.
    The Foreground Color is chosen for the brush, shapes, etc.
    Eventually, you want to read the entire content of the Help files, and maybe, hopefully, a book like " Photoshop Classroom in a Book".
    Photoshop is a professional level application that makes no apologies for its long and steep learning curve.
    Take a class at a community college.  Teaching you Photoshop from the ground up far exceeds the scope of the forum.

  • How to get the default selection color from JTable

    Hi, there,
    I have a question for how to get the default selection color from JTable. I am currently implementing the customized table cell renderer, but I do want to set the selection color in the table exactly the same of default table cell renderer. The JTable.getSelectionBackgroup() did not works for me, it returned dark blue which made the text in the table unreadable. Anyone know how to get the window's default selection color?
    Thanks,
    -Jenny

    The windows default selection color is dark blue. Try selecting any text on this page. The difference is that the text gets changed to a white font so you can actually see the text.
    If you don't like the default colors that Java uses then use the UIManager to change the defaults. The following program shows all the properties controlled by the UIManager:
    http://www.discoverteenergy.com/files/ShowUIDefaults.java
    Any of the properties can be changed for the entire application by using:
    UIManager.put( "propertyName", value );

  • How to get the Swatch Options Color Type?

    How to get the Swatch Options Color Type name that is "Process Color" or "Spot Color" which shown in the Color Type via scripting..
    Thanks...

    Could you please provide any example for how to get the color type name that is process or spot. Thanks for looking into this.
    Advance thanks,
    Maria Prabudass

  • How to change the selection background color of the selected item in the popup menu of the choice box ?

    How to change the selection background color of the selected item in the popup menu of the choice box ?
    By defaut, the selection background color likes "blue", but if I want it to be "yellow" for example, how should I do ?
    Thanks

    The id is applied by (I think) the skin class of the ChoiceBox. You don't need to define it.
    You have to apply the css in an external style sheet. You can apply the external style sheet to any parent of your choice box, or to the scene (the most usual way to do it).
    Example:
    import java.util.ArrayList;
    import java.util.List;
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.ChoiceBox;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    public class ChoiceBoxTest extends Application {
      @Override
      public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("Example 2");
        final ChoiceBox<String> choiceBox = new ChoiceBox<>();
        List<String> tempResult = new ArrayList<String>();
        for (int i = 0; i < 10; i++) {
          tempResult.add("Item " + i);
        choiceBox.getItems().setAll(tempResult);
        VBox root = new VBox();
        root.getChildren().add(choiceBox);
        final Scene scene = new Scene(root, 300, 250);
        scene.getStylesheets().add("choiceBox.css");
        primaryStage.setScene(scene);
        primaryStage.show();   
      public static void main(String[] args) {
        launch(args);
    choiceBox.css:
    @CHARSET "UTF-8";
    #choice-box-menu-item:focused  {
    -fx-background-color: yellow ;
    #choice-box-menu-item .label {
    -fx-text-fill: black ;
    Message was edited by: James_D

  • How can I set the foreground/background color after using CSPickColor()?

    Hello all,
    Is there any one who has experience on changing foreground or background color using Photoshop Plug-in SDK?
    Currently I can get a returned color from CSPickColor(), but have no idea how to use it.
    Thanks!

    You can try a linear-gradient that starts at gray 0% and ends at white <whatever the percentage the thumb is at>.
            final Node track = slider.lookup(".track");
            slider.valueProperty().addListener(new ChangeListener<Number>() {
                public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
                    double pct = (t1.doubleValue()-slider.getMin())/(slider.getMax()-slider.getMin())*100;
                    track.setStyle("-fx-background-color: linear-gradient(to right, gray, gray " + pct + "%, white" + pct + "%, white);");
            });Edited by: dgrieve on Apr 12, 2012 12:19 PM

  • How can I get the foreground/background swatches in my panel?

    Howdy all-
    Been loving this forum, it's been extremely helpful getting started with Configurator. I'm pulling together a panel for my students to guide their retouching work and the last thing I am trying to get in is the foreground/background swatches like at the bottom of the toolbar. Is this possible? I haven't found it in the provided libraries- is it something that would need a script or am I looking in the wrong places?
    thanks so much again for the forum and any help anyone can provide.

    Hi
    You can only switch foreground/background color   or   set them to default color
    As in the previous thread ( by ipf55 )
    you have the possibility to insert the color picker.
    so the workaround is :
    switch to foreground ( or background as you prefer)
    choose a color with the color picker button (Now the foreground is  set with the color you choosed)
    then repeat te step for the background
    to choose a color you could also ( e.g.) insert into your panel a button that open the swatches panel
    This is the link to develop a panel with the caratheristic i suppose you are looking for
    Adobe® Photoshop® Panel Developer's Guide
    http://www.adobe.com/devnet/photoshop/pdfs/photoshop_panel_developers_guide.pdf
    ( go to pag 26-The Color Picker Panel tutorial)
    You could also take a look to the link to  adobe exchange I mentioned in the thread  above

  • Is there any way to get the black background color back in fullscreen mode?

    The current background color in fullscreen mode is grey and it's distracting.  It used to be black.  Is there a way to change the color outside of the document boundaries?

    AndyboyMac wrote:
    The only way you can get themes for your ipod is by a jailbrake, jailbraking is illegal, and yes,, you can downgrade your iOS.
    Jailbreaking is actually not illegal due to exemptions in the DMCA documentation (http://en.wikipedia.org/wiki/IOS_jailbreaking#cite_note-22).
    I've got no explanation on to why the trusty interface for the old iPod style app was butchered, unfortunately (I think we're all at a loss, besides someone being given too much free reign). I came here to supplement the original question with, another alternative question:
    Is there a way, similar to downgrading 3rd party apps, downgrade the Music app or restore the old iPod app as an additonal app? Without jailbreaking?
    < Edited By Host >

  • How to get the silverish white color in Java

    Hi
    I want to know how to get the silver color in Java
    I am currently using
    R , G , B
    setBackground(new color(255,255,255));
    I am getting bright white color.
    How do I get the polished white(silverish white color) color.
    Thank You

    RGB Color Chart...
    http://www.htmlcenter.com/tutorials/tutorials.cfm/89/General/
    perhaps new Color(223,223,255) ???

  • How to get the Seperation setup color plates count in Illustrator 10 SDK?

    Hi All,
    Im using Microsoft VC++6.0 & Illustrator 10 SDK.
    How can i get access to "Seperation setup " property of the document.
    Actually i need to get the number of color plates inside the separation setup.
    Any sample code please.
    Thanks in advance
    Regards
    myRiaz

    It sounds like you need to figure out which part of the API deals with colour separation. It could be AIDocument.h or it could be AIColor.h. I'm afraid you'll just have to check the headers until you find something that looks like you want. You could also try searching the API for a piece of text that you'd expect to find associated with the values you're trying to pull -- that might point you in the right direction.

  • How to change the Video Background Color - The Answer...Not the Question.

    Hello All,
    I was struggling with the Video Background Color as I was setting up my DVD. I'm new to DVD Studio Pro. I couldn't get the color to change from grey to the desired black. I was moments from asking for help, but thought to try just a bit harder. The answer lies under Preferences, Menu, Video Background Color. Just thought I'd share for future search strings by others.
    Ahh, onward!
    DG

    The id is applied by (I think) the skin class of the ChoiceBox. You don't need to define it.
    You have to apply the css in an external style sheet. You can apply the external style sheet to any parent of your choice box, or to the scene (the most usual way to do it).
    Example:
    import java.util.ArrayList;
    import java.util.List;
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.ChoiceBox;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    public class ChoiceBoxTest extends Application {
      @Override
      public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("Example 2");
        final ChoiceBox<String> choiceBox = new ChoiceBox<>();
        List<String> tempResult = new ArrayList<String>();
        for (int i = 0; i < 10; i++) {
          tempResult.add("Item " + i);
        choiceBox.getItems().setAll(tempResult);
        VBox root = new VBox();
        root.getChildren().add(choiceBox);
        final Scene scene = new Scene(root, 300, 250);
        scene.getStylesheets().add("choiceBox.css");
        primaryStage.setScene(scene);
        primaryStage.show();   
      public static void main(String[] args) {
        launch(args);
    choiceBox.css:
    @CHARSET "UTF-8";
    #choice-box-menu-item:focused  {
    -fx-background-color: yellow ;
    #choice-box-menu-item .label {
    -fx-text-fill: black ;
    Message was edited by: James_D

  • [i]How to change the[/i]   background color in a webdynpro?

    Does somebody know how I can simpley change the background color in a webdynpro?

    You need to use external CSS..via the sap-ep-themeroot or sap-cssurl.
    For downloading and changing CSS. pls refer to
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/7015b1f9-535c-2910-c8b7-e681fe75aaf8
    Note: as stated in the documentation for a external CSS, that is just placing it in /SAP/PUBLIC Folder, <b>did not work</b> for me....
    Do following it works..
    Create a BSP application, ZCUSTOMTHEME. GO to MIME Repository and create a folder zmytheme under ZCUSTOMTHEME
    open SE38 and execute BSP_UPDATE_MIMEREPOS and upload ur custom theme under this folder.. /sap/bc/bsp/sap/ZCUSTOMTHEME/zmytheme
    While calling ur WD application....append following at end of URL
    sap-ep-themeroot = /sap/bc/bsp/ZCUSTOMTHEME/zmytheme'

  • How to get the  name of color from the Color Object??

    hi all,
    i want to get the color name from the Color Object i.e say if the Color object is something like
    c=new Color(128,128,128);
    I should be a able to say this object is of gray color dynamically
    Can anyone help???

    You can't do this. There is no label for a color - what is 0x439803 called? 'Mud?' 'Rustic sludge?' 'Poo brown?' - and then that's just English, it might need to be 'Brun de Kaka' or something.
    If you want to check against a certain predefined color you could do the following,
    if (Color.GRAY.equals(myColor))Otherwise you'll have to write your own code to label colors.

  • How to get secondary tile background color on WP 8.1?

    Currently, all secondary tiles are returning background color #7FFFFFFF regardless of color

    Hi TaskBasic,
    >>all secondary tiles are returning background color #7FFFFFFF regardless of color
    We can use the following code to convert HEX color to Color in runtime:
    var hexCode = "#7FFFFFFF";
    var color = new Color();
    color.A = byte.Parse(hexCode.Substring(1, 2), NumberStyles.AllowHexSpecifier);
    color.R = byte.Parse(hexCode.Substring(3, 2), NumberStyles.AllowHexSpecifier);
    color.G = byte.Parse(hexCode.Substring(5, 2), NumberStyles.AllowHexSpecifier);
    color.B = byte.Parse(hexCode.Substring(7, 2), NumberStyles.AllowHexSpecifier);
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get the destination path in an photoshop sdk export plugin when using a batch action?

    Hello,
    I've written an exporter plugin (not save-as) that exports a given file to a custom format.
    I was able to open a file selector dialog and choose a path that is then transported to the saving location.
    Now my problem is: Another intended use is batch exporting many files. The user records an action with the export step and then applies a batch on it.
    The PS batch window allows you to select the destination to be a directory where the exporter should write the data. Fine.
    Now how do I get this path? When running in batch mode the silent flag is set for my plugin so I do not spawn a file selector dialog to annoy the user.
    But I am also unable to obtain the path which was selected by the user in the batch window.
    The SDK automation plugin Getter has some code to retrieve the path of the file and even that fails as it cannot obtain anything.
    PropertyUtils.h has some PIGetWorkPathIndex and PIGetPathName functions but I always get 0 when asking PIGetNumberPaths, and get -1 with PIGetWorkPathIndex.
    I would be thankful if somebody could hint me how I can retrieve directories.
    It even seems impossible for me to get the path where the file is actually saved. The filter plugin called Propertizer utilizes a function called PIGetDocumentName but this only outputs the file name, not the full path.
    (Just to be sure: The file on which the tests run is already saved to disk, if that matters)
    Another fun part is: When I record an export step, what is the directory I am exporting into?

    Ok, after lots of reading the sdk sample outbound I've realized that or plugin is broken.
    When recording an action the outbound plugin stores the current path to gAliasHandle which is then recorded as a scripting parameter. Now when I execute the action I get the alias handle.
    However how is this supposed to work with an export plugin and batch processing with a "destination" set to a target? Is this even possible or do I need to double click the export step in the action and "reset" the location even if that causes the entire exporter to run again?

Maybe you are looking for

  • Summing up a Column in ALV report

    Hi All, I have developed an ALV Report which will display Invoices and other details. Now i need to display the sum of NETWR column, if user wish to select that column and click the "SUM" icon. As of now, if i select the NETWR column and click 'SUM"

  • Where is the file drop down to open files on my computer that's a biggie

    Hello on the version FIREFOX I have their is a file dropdown that allows me to get files from my computer the link in the upper left hand corner says FILE and I click it and and their is a several links such as NEW WINDOW/ NEW TAB/ OPEN LOCATION/ OPE

  • Why were my PDFs so small in Megabytes size?

    Hi, Just something that has been bugging me - I recently sent 64 pages of a magazine to the printers with each page exported as a seperate pdf using the press quality preset. I was surprised and alarmed at the small file sizes of the pdfs - many page

  • Analog clock -- with numbers?

    I like the analog clock on the external screen of my Style, but it can be difficult to read at a quick glance, since it has no numbers, and the 5-minute marks are all the same size. Is there any way of having a clock that looks just like the current

  • Crystal Reports Server XI Infoview Error Messages

    Just upgraded to Crystal Reports Server XI Release 2. I can create reports and save them using the enterprise method. The reports run fine in Crystal reports but when I try to view a report using Infoview I get the following messages: Unable to retri