Is it possible to pop-up a Dialog Window on to the cursor coordinates? by scripting in PS.

Explorer ,
Apr 07, 2022 Apr 07, 2022

Copy link to clipboard

Copied

hello.

I want ask some question to scripting in Photoshop.

I made a Color Palette script in Photoshop just to help my workflow.

This can keep a few temporarily color. king of auxiliary function for my painting.

 

I'm not a programmer. So ,I think my code is ugly but it's ok.

It's works fine for myself.

Now the question is ,is it possible to pop-up Dialog Window on to a brush cursor coordinates?

If some one know how to do,please let me know.

thank you in advance.

 

 

//make folder
var fColor= app.foregroundColor;
var dPath = ("~/desktop")
var bcForder= new Folder(dPath+"/bColorLog/palette/");
bcForder.create();

//terminal access
var tlog = File(dPath+"/bColorLog/terminal.data");
var check1 = tlog.open("r");
if(check1==false){
    var bColorLog= new File(dPath+"/bColorLog/palette/palette_0.data");
    bColorLog.open('w');
    bColorLog.write('1,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,400,400,1');
    bColorLog.close();

    //get palette list
    var fnList = new Array();
    var lists = bcForder.getFiles();
    for(i=0;i<lists.length;i++){fnList.push(lists[i]);}

    //make terminal file
    var tlog= new File(dPath+"/bColorLog/terminal.data");
    tlog.open('w');
    tlog.write(lists[0]+",1,400,400");
    var check2 = tlog.open("r");
    if(check2==false){
      var dPath = ("~/デスクトップ")
      var bColorLog= new File(dPath+"/bColorLog/palette/palette_0.data");
      bColorLog.open('w');
      bColorLog.write('1,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,400,400,1');
      bColorLog.close();
  
      var fnList = new Array();
      var lists = bcForder.getFiles();
      for(i=0;i<lists.length;i++){fnList.push(lists[i]);}
  
      var tlog= new File(dPath+"/bColorLog/terminal.data");
      tlog.open('w');
      tlog.write(lists[0]+",1,400,400");
      tlog.open("r");
    }
}
//get terminal URL
var terminal1 = tlog.read();
tlog.close();
var terminal=terminal1.split(',');
var bColorLog=File(terminal[0]);
var pNameURL = terminal[0].split("/");
var pNameOnly = pNameURL[pNameURL.length-1];
var pName = pNameOnly.split(".")
var paletteName = pName[0];

//palette access
bColorLog.open("r");
var bC=bColorLog.read();
var bArray=bC.split(',');

//open Window dialog
var dialog = new Window("dialog"); 
    dialog.text = paletteName+" Slot ["+bArray[0]+"]"; 
    dialog.alignChildren = ["center","top"]; 
    dialog.spacing = 10; 
    dialog.margins = 16; 
  dialog.onShow = function(){    
    var ww = dialog.bounds.width;    
    var hh = dialog.bounds.height;  
    dialog.bounds.x = terminal[2];    
    dialog.bounds.y = terminal[3];    
    dialog.bounds.width  = ww;    
    dialog.bounds.height  = hh; 
  } 

//make window group
var group1 = dialog.add("group", undefined, {name: "group1"}); 
group1.orientation = "row"; 
group1.alignChildren = ["left","center"]; 
group1.spacing = 10; 
group1.margins = 0; 

var group2 = dialog.add("group", undefined, {name: "group2"}); 
group2.orientation = "row"; 
group2.alignChildren = ["left","center"]; 
group2.spacing = 10; 
group2.margins = 0; 

var group3 = dialog.add("group", undefined, {name: "group3"}); 
group3.orientation = "row"; 
group3.alignChildren = ["left","center"]; 
group3.spacing = 10; 
group3.margins = 0; 

var checkbox1 = dialog.add("checkbox", undefined, undefined, {name: "checkbox1"}); 
checkbox1.text = "stuck Slot";
checkbox1.alignment = ["right","top"]; 

var group4 = dialog.add("group", undefined, {name: "group4"}); 
group4.orientation = "row"; 
group4.alignment = ["right","top"]; 
group4.spacing = 10; 
group4.margins = 0; 

var group5 = dialog.add("group", undefined, {name: "group5"}); 
group5.orientation = "row"; 
group5.alignChildren = ["left","center"]; 
group5.spacing = 10; 
group5.margins = 0; 

//make clean button
var cleanButton = group4.add("button", undefined, undefined, {name: "button1"}); 
cleanButton.text = "clean"; 
cleanButton.alignment = ["right","top"];
cleanButton.onClick = function(){
  dialog.close(),
  clean()
};


//make save button
var saveButton = group5.add("button", undefined, undefined, {name: "buttonS"}); 
saveButton.text = "SAVE"; 
saveButton.onClick = function(){
  dialog.close(),
  terminal[2] = dialog.bounds.x,
  terminal[3] = dialog.bounds.y,
  tlog.open("w");
  tlog.write(terminal[0]+",0,"+terminal[2]+","+terminal[3])
  tlog.close();
  openSave()
};
//make load button
var loadButton = group5.add("button", undefined, undefined, {name: "buttonL"}); 
loadButton.text = "LOAD"; 
loadButton.onClick = function(){
    dialog.close(),
    terminal[2] = dialog.bounds.x,
    terminal[3] = dialog.bounds.y,
    tlog.open("w");
    tlog.write(terminal[0]+",0,"+terminal[2]+","+terminal[3])
    tlog.close();
    openLoad()
};
//make delete button
var deleteButton = group5.add("button", undefined, undefined, {name: "buttonD"}); 
deleteButton.text = "Delete Palette";
deleteButton.onClick = function(){
  dialog.close(),
  terminal[2] = dialog.bounds.x,
  terminal[3] = dialog.bounds.y,
  tlog.open("w");
  tlog.write(terminal[0]+",0,"+terminal[2]+","+terminal[3])
  tlog.close();
  openDelete()
};

//make ok button
var okButton = group5.add("button", undefined, undefined, {name: "buttonOK"}); 
okButton.text = "OK"; 
okButton.onClick = function() {
  //update palette
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  bColorLog.open('w');
  bColorLog.write(bArray);
  bColorLog.close();  
  //update terminal
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3])
  tlog.close();
  dialog.close();
};

//change slot color to recent color
if(bArray[48] == 1){
    checkbox1.value = true
}else{checkbox1.value = false};

var bSize = 5
if(terminal[1]==1){
    if(checkbox1.value == false){
      var calc = Number(bArray[0])
      bArray[calc*3-2] = fColor.rgb.red;
      bArray[calc*3-1] = fColor.rgb.green;
      bArray[calc*3] = fColor.rgb.blue;
      bColorLog.write(bArray);
    }
  };
try{
//top palette array
//123  
if (bArray[0]==1){
  var panel1 = group1.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button1 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button1 = group1.add("button", undefined, undefined, {name: "button1"}); 
  };
button1.fillBrush = button1.graphics.newBrush( button1.graphics.BrushType.SOLID_COLOR, [bArray[1]/255,bArray[2]/255,bArray[3]/255,1] )
button1.onDraw = function(){
  with( this ) {
    graphics.drawOSControl();
    graphics.rectPath(0,0,size[0],size[0]);
    graphics.fillPath(fillBrush);
  }
};
button1.onClick = function() {
  var cObj= new SolidColor();
  cObj.rgb.red= bArray[1];
  cObj.rgb.green= bArray[2];
  cObj.rgb.blue= bArray[3];
  app.foregroundColor= cObj;  
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  var newArray=[1,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
  bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
  bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
  bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
  bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
  bColorLog.open('w');
  bColorLog.write(newArray);
  bColorLog.close();
  //terminal button cordinate
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
  tlog.close();
  dialog.close();
  };
//456
if (bArray[0]==2){
  var panel1 = group1.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button2 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button2 = group1.add("button", undefined, undefined, {name: "button1"}); 
  };
button2.fillBrush = button2.graphics.newBrush( button2.graphics.BrushType.SOLID_COLOR, [bArray[4]/255,bArray[5]/255,bArray[6]/255,1] );
button2.onDraw = function(){
  with( this ) {
    graphics.drawOSControl();
    graphics.rectPath(0,0,size[0],size[1]);
    graphics.fillPath(fillBrush);
  }
};
button2.onClick = function() {
  var cObj= new SolidColor();
  cObj.rgb.red= bArray[4];
  cObj.rgb.green= bArray[5];
  cObj.rgb.blue= bArray[6];
  app.foregroundColor= cObj;  
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  var newArray=[2,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
  bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
  bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
  bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
  bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
  bColorLog.open('w');
  bColorLog.write(newArray);
  bColorLog.close();   
  //terminal button cordinate
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
  tlog.close();
  dialog.close();
  };
//789
if (bArray[0]==3){
  var panel1 = group1.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button3 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button3 = group1.add("button", undefined, undefined, {name: "button1"}); 
  };
button3.fillBrush = button3.graphics.newBrush( button3.graphics.BrushType.SOLID_COLOR, [bArray[7]/255,bArray[8]/255,bArray[9]/255,1] );
button3.onDraw = function(){
  with( this ) {
    graphics.drawOSControl();
    graphics.rectPath(0,0,size[0],size[1]);
    graphics.fillPath(fillBrush);
  }
};
button3.onClick = function() {
  var cObj= new SolidColor();
  cObj.rgb.red= bArray[7];
  cObj.rgb.green= bArray[8];
  cObj.rgb.blue= bArray[9];
  app.foregroundColor= cObj;  
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  var newArray=[3,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
  bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
  bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
  bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
  bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
  bColorLog.open('w');
  bColorLog.write(newArray);
  bColorLog.close();   
  //terminal button cordinate
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
  tlog.close();
  dialog.close();
  };
//101112
if (bArray[0]==4){
  var panel1 = group1.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button4 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button4 = group1.add("button", undefined, undefined, {name: "button1"}); 
  };
button4.fillBrush = button4.graphics.newBrush( button4.graphics.BrushType.SOLID_COLOR, [bArray[10]/255,bArray[11]/255,bArray[12]/255,1] );
button4.onDraw = function(){
  with( this ) {
    graphics.drawOSControl();
    graphics.rectPath(0,0,size[0],size[1]);
    graphics.fillPath(fillBrush);
  }
};
button4.onClick = function() {
  var cObj= new SolidColor();
  cObj.rgb.red= bArray[10];
  cObj.rgb.green= bArray[11];
  cObj.rgb.blue= bArray[12];
  app.foregroundColor= cObj;  
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  var newArray=[4,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
  bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
  bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
  bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
  bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
  bColorLog.open('w');
  bColorLog.write(newArray);
  bColorLog.close();   
  //terminal button cordinate
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
  tlog.close();
  dialog.close();
  };
//131415
if (bArray[0]==5){
  var panel1 = group1.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button5 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button5 = group1.add("button", undefined, undefined, {name: "button1"}); 
  };
  button5.fillBrush = button5.graphics.newBrush( button5.graphics.BrushType.SOLID_COLOR, [bArray[13]/255,bArray[14]/255,bArray[15]/255,1] );
  button5.onDraw = function(){
    with( this ) {
      graphics.drawOSControl();
      graphics.rectPath(0,0,size[0],size[1]);
      graphics.fillPath(fillBrush);
    }
  };
  button5.onClick = function() {
    var cObj= new SolidColor();
    cObj.rgb.red= bArray[13];
    cObj.rgb.green= bArray[14];
    cObj.rgb.blue= bArray[15];
    app.foregroundColor= cObj;  
    if(checkbox1.value == false){
      bArray.splice(48,1,"0")
    }else if(checkbox1.value == true){
      bArray.splice(48,1,"1")
    };
    var newArray=[5,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
    bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
    bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
    bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
    bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
    bColorLog.open('w');
    bColorLog.write(newArray);
    bColorLog.close();    
    //terminal button cordinate
    terminal[2] = dialog.bounds.x;
    terminal[3] = dialog.bounds.y;
    tlog.open("w");
    tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
    tlog.close();
    dialog.close();
    };
//middle palette array
//161718
if (bArray[0]==6){
  var panel1 = group2.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button6 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button6 = group2.add("button", undefined, undefined, {name: "button1"}); 
  }; 
button6.fillBrush = button6.graphics.newBrush( button6.graphics.BrushType.SOLID_COLOR, [bArray[16]/255,bArray[17]/255,bArray[18]/255,1] );
button6.onDraw = function(){
  with( this ) {
    graphics.drawOSControl();
    graphics.rectPath(0,0,size[0],size[1]);
    graphics.fillPath(fillBrush);
  }
};
button6.onClick = function() {
  var cObj= new SolidColor();
  cObj.rgb.red= bArray[16];
  cObj.rgb.green= bArray[17];
  cObj.rgb.blue= bArray[18];
  app.foregroundColor= cObj;  
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  var newArray=[6,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
  bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
  bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
  bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
  bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
  bColorLog.open('w');
  bColorLog.write(newArray);
  bColorLog.close();   
  //terminal button cordinate
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
  tlog.close();
  dialog.close();
  };
//192021
if (bArray[0]==7){
  var panel1 = group2.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button7 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button7 = group2.add("button", undefined, undefined, {name: "button1"}); 
  }; 
button7.fillBrush = button7.graphics.newBrush( button7.graphics.BrushType.SOLID_COLOR, [bArray[19]/255,bArray[20]/255,bArray[21]/255,1] );
button7.onDraw = function(){
  with( this ) {
    graphics.drawOSControl();
    graphics.rectPath(0,0,size[0],size[1]);
    graphics.fillPath(fillBrush);
  }
};
button7.onClick = function() {
  var cObj= new SolidColor();
  cObj.rgb.red= bArray[19];
  cObj.rgb.green= bArray[20];
  cObj.rgb.blue= bArray[21];
  app.foregroundColor= cObj;  
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  var newArray=[7,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
  bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
  bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
  bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
  bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
  bColorLog.open('w');
  bColorLog.write(newArray);
  bColorLog.close();   
  //terminal button cordinate
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
  tlog.close();
  dialog.close();
  };
//2222324
if (bArray[0]==8){
  var panel1 = group2.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button8 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button8 = group2.add("button", undefined, undefined, {name: "button1"}); 
  };
button8.fillBrush = button8.graphics.newBrush( button8.graphics.BrushType.SOLID_COLOR, [bArray[22]/255,bArray[23]/255,bArray[24]/255,1] );
button8.onDraw = function(){
  with( this ) {
    graphics.drawOSControl();
    graphics.rectPath(0,0,size[0],size[1]);
    graphics.fillPath(fillBrush);
  }
};
button8.onClick = function() {
  var cObj= new SolidColor();
  cObj.rgb.red= bArray[22];
  cObj.rgb.green= bArray[23];
  cObj.rgb.blue= bArray[24];
  app.foregroundColor= cObj;  
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  var newArray=[8,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
  bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
  bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
  bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
  bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
  bColorLog.open('w');
  bColorLog.write(newArray);
  bColorLog.close();   
  //terminal button cordinate
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
  tlog.close();
  dialog.close();
  };
//252627
if (bArray[0]==9){
  var panel1 = group2.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button9 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button9 = group2.add("button", undefined, undefined, {name: "button1"}); 
  }; 
button9.fillBrush = button9.graphics.newBrush( button9.graphics.BrushType.SOLID_COLOR, [bArray[25]/255,bArray[26]/255,bArray[27]/255,1] );
button9.onDraw = function(){
  with( this ) {
    graphics.drawOSControl();
    graphics.rectPath(0,0,size[0],size[1]);
    graphics.fillPath(fillBrush);
  }
};
button9.onClick = function() {
  var cObj= new SolidColor();
  cObj.rgb.red= bArray[25];
  cObj.rgb.green= bArray[26];
  cObj.rgb.blue= bArray[27];
  app.foregroundColor= cObj;  
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  var newArray=[9,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
  bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
  bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
  bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
  bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
  bColorLog.open('w');
  bColorLog.write(newArray);
  bColorLog.close();   
  //terminal button cordinate
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
  tlog.close();
  dialog.close();
  };
//282930
if (bArray[0]==10){
  var panel1 = group2.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button10 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button10 = group2.add("button", undefined, undefined, {name: "button1"}); 
  };
  button10.fillBrush = button10.graphics.newBrush( button10.graphics.BrushType.SOLID_COLOR, [bArray[28]/255,bArray[29]/255,bArray[30]/255,1] );
  button10.onDraw = function(){
    with( this ) {
      graphics.drawOSControl();
      graphics.rectPath(0,0,size[0],size[1]);
      graphics.fillPath(fillBrush);
    }
  };
  button10.onClick = function() {
    var cObj= new SolidColor();
    cObj.rgb.red= bArray[28];
    cObj.rgb.green= bArray[29];
    cObj.rgb.blue= bArray[30];
    app.foregroundColor= cObj;  
    if(checkbox1.value == false){
      bArray.splice(48,1,"0")
    }else if(checkbox1.value == true){
      bArray.splice(48,1,"1")
    };
    var newArray=[10,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
    bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
    bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
    bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
    bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
    bColorLog.open('w');
    bColorLog.write(newArray);
    bColorLog.close();    
    //terminal button cordinate
    terminal[2] = dialog.bounds.x;
    terminal[3] = dialog.bounds.y;
    tlog.open("w");
    tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
    tlog.close();
    dialog.close();
    };
//bottom palette array
//313233
if (bArray[0]==11){
  var panel1 = group3.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button11 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button11 = group3.add("button", undefined, undefined, {name: "button1"}); 
  };
button11.fillBrush = button11.graphics.newBrush( button11.graphics.BrushType.SOLID_COLOR, [bArray[31]/255,bArray[32]/255,bArray[33]/255,1] );
button11.onDraw = function(){
  with( this ) {
    graphics.drawOSControl();
    graphics.rectPath(0,0,size[0],size[1]);
    graphics.fillPath(fillBrush);
  }
};
button11.onClick = function() {
  var cObj= new SolidColor();
  cObj.rgb.red= bArray[31];
  cObj.rgb.green= bArray[32];
  cObj.rgb.blue= bArray[33];
  app.foregroundColor= cObj;  
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  var newArray=[11,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
  bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
  bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
  bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
  bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
  bColorLog.open('w');
  bColorLog.write(newArray);
  bColorLog.close();   
  //terminal button cordinate
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
  tlog.close();
  dialog.close();
  };
//343536
if (bArray[0]==12){
  var panel1 = group3.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button12 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button12 = group3.add("button", undefined, undefined, {name: "button1"}); 
  };
button12.fillBrush = button12.graphics.newBrush( button12.graphics.BrushType.SOLID_COLOR, [bArray[34]/255,bArray[35]/255,bArray[36]/255,1] );
button12.onDraw = function(){
  with( this ) {
    graphics.drawOSControl();
    graphics.rectPath(0,0,size[0],size[1]);
    graphics.fillPath(fillBrush);
  }
};
button12.onClick = function() {
  var cObj= new SolidColor();
  cObj.rgb.red= bArray[34];
  cObj.rgb.green= bArray[35];
  cObj.rgb.blue= bArray[36];
  app.foregroundColor= cObj;  
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  var newArray=[12,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
  bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
  bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
  bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
  bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
  bColorLog.open('w');
  bColorLog.write(newArray);
  bColorLog.close();   
  //terminal button cordinate
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
  tlog.close();
  dialog.close();
  };
//373839
if (bArray[0]==13){
  var panel1 = group3.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button13 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button13 = group3.add("button", undefined, undefined, {name: "button1"}); 
  };
button13.fillBrush = button13.graphics.newBrush( button13.graphics.BrushType.SOLID_COLOR, [bArray[37]/255,bArray[38]/255,bArray[39]/255,1] );
button13.onDraw = function(){
  with( this ) {
    graphics.drawOSControl();
    graphics.rectPath(0,0,size[0],size[1]);
    graphics.fillPath(fillBrush);
  }
};
button13.onClick = function() {
  var cObj= new SolidColor();
  cObj.rgb.red= bArray[37];
  cObj.rgb.green= bArray[38];
  cObj.rgb.blue= bArray[39];
  app.foregroundColor= cObj;
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  var newArray=[13,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
  bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
  bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
  bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
  bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
  bColorLog.open('w');
  bColorLog.write(newArray);
  bColorLog.close();   
  //terminal button cordinate
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
  tlog.close();
  dialog.close();
  };
//404142
if (bArray[0]==14){
  var panel1 = group3.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button14 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button14 = group3.add("button", undefined, undefined, {name: "button1"}); 
  };
button14.fillBrush = button14.graphics.newBrush( button14.graphics.BrushType.SOLID_COLOR, [bArray[40]/255,bArray[41]/255,bArray[42]/255,1] );
button14.onDraw = function(){
  with( this ) {
    graphics.drawOSControl();
    graphics.rectPath(0,0,size[0],size[1]);
    graphics.fillPath(fillBrush);
  }
};
button14.onClick = function() {
  var cObj= new SolidColor();
  cObj.rgb.red= bArray[40];
  cObj.rgb.green= bArray[41];
  cObj.rgb.blue= bArray[42];
  app.foregroundColor= cObj;  
  if(checkbox1.value == false){
    bArray.splice(48,1,"0")
  }else if(checkbox1.value == true){
    bArray.splice(48,1,"1")
  };
  var newArray=[14,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
  bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
  bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
  bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
  bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
  bColorLog.open('w');
  bColorLog.write(newArray);
  bColorLog.close();   
  //terminal button cordinate
  terminal[2] = dialog.bounds.x;
  terminal[3] = dialog.bounds.y;
  tlog.open("w");
  tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
  tlog.close();
  dialog.close();
  };
//434445
if (bArray[0]==15){
  var panel1 = group3.add("panel", undefined, undefined, {name: "panel1"}); 
      panel1.orientation = "column"; 
      panel1.alignChildren = ["left","top"]; 
      panel1.spacing = bSize; 
      panel1.margins = bSize; 
      var g = panel1.graphics;
      var brush = g.newBrush( g.BrushType.SOLID_COLOR, [0.7, 0.7, 0.7, 1] );      
      g.backgroundColor = brush;
  var button15 = panel1.add("button", undefined, undefined, {name: "button1"}); 
  }
  else{
  var button15 = group3.add("button", undefined, undefined, {name: "button1"}); 
  };
  button15.fillBrush = button15.graphics.newBrush( button15.graphics.BrushType.SOLID_COLOR, [bArray[43]/255,bArray[44]/255,bArray[45]/255,1] );
  button15.onDraw = function(){
    with( this ) {
      graphics.drawOSControl();
      graphics.rectPath(0,0,size[0],size[1]);
      graphics.fillPath(fillBrush);
    }
  };
  button15.onClick = function() {
    var cObj= new SolidColor();
    cObj.rgb.red= bArray[43];
    cObj.rgb.green= bArray[44];
    cObj.rgb.blue= bArray[45];
    app.foregroundColor= cObj;
    if(checkbox1.value == false){
      bArray.splice(48,1,"0")
    }else if(checkbox1.value == true){
      bArray.splice(48,1,"1")
    };
    var newArray=[15,bArray[1],bArray[2],bArray[3],bArray[4],bArray[5],bArray[6],bArray[7],
    bArray[8],bArray[9],bArray[10],bArray[11],bArray[12],bArray[13],bArray[14],bArray[15],bArray[16],bArray[17],
    bArray[18],bArray[19],bArray[20],bArray[21],bArray[22],bArray[23],bArray[24],bArray[25],bArray[26],bArray[27],
    bArray[28],bArray[29],bArray[30],bArray[31],bArray[32],bArray[33],bArray[34],bArray[35],bArray[36],bArray[37],
    bArray[38],bArray[39],bArray[40],bArray[41],bArray[42],bArray[43],bArray[44],bArray[45],bArray[46],bArray[47],bArray[48]];
    bColorLog.open('w');
    bColorLog.write(newArray);
    bColorLog.close();    
    //terminal button cordinate
    terminal[2] = dialog.bounds.x;
    terminal[3] = dialog.bounds.y;
    tlog.open("w");
    tlog.write(terminal[0]+",1,"+terminal[2]+","+terminal[3]);
    tlog.close();
    dialog.close();
    };
  }catch(e){
    alert("not found palette data")
  };
dialog.show();

function openSave() {
  //pop up save button dialog window
  var dialogSave = new Window("dialog"); 
  dialogSave.text = "save palette"; 
  dialogSave.alignChildren = ["center","top"]; 
  dialogSave.spacing = 10; 
  dialogSave.margins = 16; 
  dialogSave.onShow = function(){    
    var ww = dialogSave.bounds.width;    
    var hh = dialogSave.bounds.height;  
    dialogSave.bounds.x = terminal[2];    
    dialogSave.bounds.y = terminal[3];    
    dialogSave.bounds.width  = ww;    
    dialogSave.bounds.height  = hh; 
  } 
  var confirmtxt = dialogSave.add("statictext", undefined, undefined, {name: "statictext1"}); 
  confirmtxt.text = "Do not use \ / : , ; * ? \u0022 < > | to file name."; 

  var group1 = dialogSave.add("group", undefined, {name: "group1"}); 
      group1.orientation = "row"; 
      group1.alignChildren = ["left","center"]; 
      group1.spacing = 10; 
      group1.margins = 0; 
  var edittext1 = group1.add('edittext {properties: {name: "edittext1"}}'); 
      edittext1.text = paletteName; 
      edittext1.preferredSize.width = 200;
  var sbutton = group1.add("button", undefined, undefined, {name: "button1"}); 
      sbutton.text = "SAVE"; 
  
  //get palette name list
  var fnList = new Array();
  var lists = bcForder.getFiles();
  tlog.open("r");
  var tInfo = tlog.read();
  var tURL = tInfo.split(".")
  var filename = tURL[0].split("/")
  var terminalName = filename[filename.length-1]
  for(i=0;i<lists.length;i++){      
      var fName = lists[i].name
      var tName = decodeURI(fName)
      var nameOnly = tName.split(".")
      fnList.push(nameOnly[0]);
  };
  for(i=0; i<fnList.length; i++){
    if(fnList[i]==terminalName){var num = i};
  };
  //add listbox
  var listbox1_array = fnList; 
  var listbox1 = dialogSave.add("listbox", undefined, undefined, {name: "listbox1", items: listbox1_array,multiselect:false});
  listbox1.selection = num;
  listbox1.alignment = ["left","top"]; 

  sbutton.onClick = function() {
    //update terminal
    terminal[2] = dialog.bounds.x;
    terminal[3] = dialog.bounds.y;
    var newFilesave= new File(dPath+"/bColorLog/palette/"+edittext1.text+".data");
    if(checkbox1.value == false){
      bArray.splice(48,1,"0")
    }else if(checkbox1.value == true){
      bArray.splice(48,1,"1")
    };
    newFilesave.open('w');
    newFilesave.write(bArray);
    newFilesave.close();
    tlog.open("w");
    tlog.write(dPath+"/bColorLog/palette/"+edittext1.text+".data,0,"+terminal[2]+","+terminal[3]);
    tlog.close();
    dialogSave.close();
    //rerun script
    var idAdobeScriptAutomationScripts = stringIDToTypeID( "AdobeScriptAutomation Scripts" );
      var ICP = new ActionDescriptor();
      var idjsNm = charIDToTypeID( "jsNm" );
      ICP.putString( idjsNm, "InstantColorPalette" );
    executeAction( idAdobeScriptAutomationScripts, ICP, DialogModes.NO );
  }
  dialogSave.show();
};

function openLoad() {
  //get palette name list
  var fnList = new Array();
  var lists = bcForder.getFiles();
  tlog.open("r");
  var tInfo = tlog.read();
  var tURL = tInfo.split(".")
  var filename = tURL[0].split("/")
  var terminalName = filename[filename.length-1]
  for(i=0;i<lists.length;i++){      
      var fName = lists[i].name
      var tName = decodeURI(fName)
      var nameOnly = tName.split(".")
      fnList.push(nameOnly[0]);
  };
  for(i=0; i<fnList.length; i++){
    if(fnList[i]==terminalName){var num = i};
  };
  //pop up load button dialog window
  var dialogLoad = new Window("dialog"); 
  dialogLoad.text = "load palette"; 
  dialogLoad.alignChildren = ["center","top"]; 
  dialogLoad.spacing = 10; 
  dialogLoad.margins = 16; 
  dialogLoad.onShow = function(){    
    var ww = dialogLoad.bounds.width;    
    var hh = dialogLoad.bounds.height;  
    dialogLoad.bounds.x = terminal[2];    
    dialogLoad.bounds.y = terminal[3];    
    dialogLoad.bounds.width  = ww;    
    dialogLoad.bounds.height  = hh; 
  } 
  var group1 = dialogLoad.add("group", undefined, {name: "group1"}); 
    group1.orientation = "row"; 
    group1.alignChildren = ["left","center"]; 
    group1.spacing = 10; 
    group1.margins = 0; 
  var listbox1_array = fnList; 
  var listbox1 = group1.add("listbox", undefined, undefined, {name: "listbox1", items: listbox1_array,multiselect:false});
  listbox1.selection = num;
  var lButton = group1.add("button", undefined, undefined, {name: "button1"}); 
  lButton.text = "LOAD";
  lButton.onClick = function() {
    //update palette
    if(checkbox1.value == false){
      bArray.splice(48,1,"0")
    }else if(checkbox1.value == true){
      bArray.splice(48,1,"1")
    };
    bColorLog.open('w');
    bColorLog.write(bArray);
    bColorLog.close();
    //update terminal
    terminal[2] = dialog.bounds.x;
    terminal[3] = dialog.bounds.y;
    tlog.open("w");
    tlog.write(dPath+"/bColorLog/palette/"+String(listbox1.selection)+".data,0,"+terminal[2]+","+terminal[3]);
    tlog.close();
    dialogLoad.close();
    //rerun script
    var idAdobeScriptAutomationScripts = stringIDToTypeID( "AdobeScriptAutomation Scripts" );
      var ICP = new ActionDescriptor();
      var idjsNm = charIDToTypeID( "jsNm" );
      ICP.putString( idjsNm, "InstantColorPalette" );
    executeAction( idAdobeScriptAutomationScripts, ICP, DialogModes.NO );
  };
  dialogLoad.show();
};

function openDelete() {
    //get palette name list
    tlog.open("r");
    var tInfo = tlog.read();
    var tURL = tInfo.split(".")
    var filename = tURL[0].split("/")
    var terminalName = filename[filename.length-1]
    var snList = new Array();
    var lists = bcForder.getFiles();
    for(i=0;i<lists.length;i++){        
        var fName = lists[i].name
        var tName = decodeURI(fName)
        var nameOnly = tName.split(".")
        snList.push(nameOnly[0]);
    };
    for(i=0; i<snList.length; i++){
      if(snList[i]==terminalName){var num = i};
    };
    snList.splice(num,1);
      
    //pop up delete button dialog window
    var dialogDelete = new Window("dialog"); 
    dialogDelete.text = "Delete"; 
    dialogDelete.alignChildren = ["center","top"]; 
    dialogDelete.spacing = 10; 
    dialogDelete.margins = 16; 
    dialogDelete.onShow = function(){    
      var ww = dialogDelete.bounds.width;    
      var hh = dialogDelete.bounds.height;  
      dialogDelete.bounds.x = terminal[2];    
      dialogDelete.bounds.y = terminal[3];    
      dialogDelete.bounds.width  = ww;    
      dialogDelete.bounds.height  = hh; 
    } 
    var group1 = dialogDelete.add("group", undefined, {name: "group1"}); 
        group1.orientation = "row"; 
        group1.alignChildren = ["left","center"]; 
        group1.spacing = 10; 
        group1.margins = 0; 
    var listbox1_array = snList; 
    var listbox1 = group1.add("listbox", undefined, undefined, {name: "listbox1", items: listbox1_array,multiselect:true}); 
    var delbutton = group1.add("button", undefined, undefined, {name: "button1"}); 
    delbutton.text = "Delete palette"; 
    delbutton.onClick = function() {
      try{
          var numListSelection = listbox1.selection.length;
          if(numListSelection==1){
            var nameListSelection = String(listbox1.selection)
            var fObj= File(dPath+"/bColorLog/palette/"+nameListSelection+".data");
            fObj.remove();
          }else{
            for(i=0;i<numListSelection;i++){
              var nameListSelection = String(listbox1.selection[i])
              var fObj= File(dPath+"/bColorLog/palette/"+nameListSelection+".data");
              fObj.remove();
             };
          }
        }catch(e){
        alert("no selection");
        };
      dialogDelete.close();
      //rerun script
      var idAdobeScriptAutomationScripts = stringIDToTypeID( "AdobeScriptAutomation Scripts" );
        var ICP = new ActionDescriptor();
        var idjsNm = charIDToTypeID( "jsNm" );
        ICP.putString( idjsNm, "InstantColorPalette" );
      executeAction( idAdobeScriptAutomationScripts, ICP, DialogModes.NO );
    }
    dialogDelete.show();
};

function clean(){
  bColorLog.open('w');
  bColorLog.write('1,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,400,400,0');
  bColorLog.close();
  terminal[2] = dialog.bounds.x,
  terminal[3] = dialog.bounds.y,
  tlog.open("w");
  tlog.write(terminal[0]+",0,"+terminal[2]+","+terminal[3])
  tlog.close();
  //rerun script
  var idAdobeScriptAutomationScripts = stringIDToTypeID( "AdobeScriptAutomation Scripts" );
    var ICP = new ActionDescriptor();
    var idjsNm = charIDToTypeID( "jsNm" );
    ICP.putString( idjsNm, "InstantColorPalette" );
  executeAction( idAdobeScriptAutomationScripts, ICP, DialogModes.NO );
;}
TOPICS
Actions and scripting , Windows

Views

100

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 07, 2022 Apr 07, 2022

Copy link to clipboard

Copied

Checked on CS6. Working.

var ms_x;
var ms_y;

var p = new Window("palette", undefined, undefined, { borderless: true } );

function handle(e) { p.close(); ms_x = e.screenX; ms_y = e.screenY;}

p.preferredSize = [$.screens[0].right, $.screens[0].bottom];
p.margins = 0;
p.addEventListener ("mousemove", handle, false);
p.opacity = 0.01;
p.show();

while (p.visible)
    {
    app.bringToFront();
    }

var d = new Window("dialog");

d.onShow = function()
    {
    var w = d.bounds[2]-d.bounds[0];
    var h = d.bounds[3]-d.bounds[1];

    try { if (ms_x != undefined) d.bounds = [ms_x, ms_y, ms_x+w, ms_y+h]; } catch(e) { alert(e); }
    }

d.show()

 

Maybe someone will check and finalize on a modern photoshop?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 07, 2022 Apr 07, 2022

Copy link to clipboard

Copied

It seems in 23.2.2 it doesn't react for mouse events 😞

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 08, 2022 Apr 08, 2022

Copy link to clipboard

Copied

thank you for your reply.

Bad luck ,it's couldn't work in a recent version of PSCC.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 08, 2022 Apr 08, 2022

Copy link to clipboard

Copied

LATEST

If anyone has previous Ps CC it's worth to try it in. When it works, then report new bug.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines