IanBarber
Contributor
IanBarber
Contributor
Activity
‎Mar 11, 2020
03:11 PM
alert(result); <-- returns true if(result == true){ alert("we are here"); <-- this does not get executed
... View more
‎Mar 11, 2020
03:02 PM
Adding alert(result); before the if statement returns false if I choose No on the prompt the code doesnt run (which is good) but.. if I choose Yes on the prompt the alert gives me true and code does not run either.
... View more
‎Mar 11, 2020
02:32 PM
I thought I had fixed this but I havent so I am throwing it out to the experts for some help. In the html panel, I have a Combo Box. If the user chooses Excel, it open up a MS Excel file and if the user chooses Numbers, it opens up an Apple numbers file. Both of these reside in a subfolder of the extension panel. I am using csInterface.getSystemPath(SystemPath.EXTENSION) to get the path to the files I am using csInterface.evalScript to execute the file. The user is prompted to make sure they want to do this. The prompt is coming from the photoshop.jsx file HTML (index.html) <select id="spreadsheet">
<option value="">Choose Your Spreadsheet</option>
<option value="Excel">Microsoft Excel</option>
<option value="Numbers">Apple Numbers</option>
</select> main.js $("#spreadsheet").change(function() {
if($(this).val() == "Numbers") { //user chose numbers
csInterface.evalScript('Apple_Numbers()',function(result) { //call function in jsx file and bring back the result
if(result = "yes"){ //user chose yes from the prompt
var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION);
var extensionRoot = "" + extensionRoot + "/spreadsheet/"; //path to the file
var myfile="project1.numbers"; // File Name
csInterface.evalScript('File("' + extensionRoot + myfile +'").execute()'); //open the file
}
}); photoshop.jsx function Apple_Numbers(){
var result = confirm ("This Will Open Apple Numbers\nAre you Sure?","");
if(result === true){
return result;
}
else if (result === false) {
return result;
} Problem: If I select No in the promp dialog, I am getting False returned back to the main.js file but yet it is is still executing the code and I cannot see why. Ian
... View more
‎Mar 11, 2020
02:25 PM
I thought I had fixed this but I havent so I am throwing it out to the experts for some help. In the html panel, I have a Combo Box. If the user chooses Excel, it open up a MS Excel file and if the user chooses Numbers, it opens up an Apple numbers file. Both of these reside in a subfolder of the extension panel. I am using csInterface.getSystemPath(SystemPath.EXTENSION) to get the path to the files I am using csInterface.evalScript to execute the file. The user is prompted to make sure they want to do this. The prompt is coming from the photoshop.jsx file HTML (index.html) <select id="spreadsheet"> <option value="">Choose Your Spreadsheet</option> <option value="Excel">Microsoft Excel</option> <option value="Numbers">Apple Numbers</option> </select> main.js $("#spreadsheet").change(function() { if($(this).val() == "Numbers") { //user chose numbers csInterface.evalScript('Apple_Numbers()',function(result) { //call function in jsx file and bring back the result if(result = "yes"){ //user chose yes from the prompt var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION); var extensionRoot = "" + extensionRoot + "/spreadsheet/"; //path to the file var myfile="project1.numbers"; // File Name csInterface.evalScript('File("' + extensionRoot + myfile +'").execute()'); //open the file } }); Photoshop.jsx function Apple_Numbers(){ var result = confirm ("This Will Open Apple Numbers\nAre you Sure?",""); if(result === true){ return result; } else if (result === false) { return result; } Problem: If I select No in the prompt dialog, I am getting False returned back to the main.js file but yet it is is still executing the code and I cannot see why. Ian
... View more
‎Mar 09, 2020
05:09 AM
I am using the following code to open the FileSaveAs Dialog var file = File.saveDialog('Save info', 'Info:*.txt'); On a Mac there is no File Extension added unlike in Windows. Is there a way to force an extension or this just the way it works on MAC Ian
... View more
‎Mar 07, 2020
06:01 AM
Photoshop 2020 21.1.0 Mac Catalina OSX For some time I have noticed that Photoshop grabs focus which can be annoying. Scenario: I have Photoshop open but then decide to do something else like reply to an email. A few seconds later, Photoshop seems to come to the front on its own. Its as though its on a timer and does it after so long. I cant think of any OSX settings I may have missed. Any thoughts ? Ian
... View more
‎Feb 24, 2020
07:58 AM
I know that the Custom Curve Presets on the MAC are stored in ~/USERNAME/Library/Application Support/Adobe/Adobe Photoshop 2020/Presets/Curves but how does one navigate to that location from the Save Preset option because by default, the ~/USERNAME/Libray folder is hidden on the MAC. Ian
... View more
‎Feb 21, 2020
07:38 AM
Thank you. So basically, when the button is pressed it closes the Dialog and then carries on to run the ShowMeSecond() function Ian
... View more
‎Feb 21, 2020
07:07 AM
I have a simple Dialog with a Button. When the button pressed, I want it to close the Dialog and open another one. This works but when the second Dialog is opened, it doesn't have focus. Question: Is there a way to make this second Dialog have focus after the code has run ? For the Buton onClick I am using button2.onClick = function(){
dialog.close();
ShowMe(); // call this function to open 2nd Dialog
} and the contents of the ShowMe function is function ShowMe(){
var w = new Window("dialog");
w.text = "Dialog";
w.orientation = "column";
w.alignChildren = ["center","top"];
w.spacing = 10;
w.margins = 16;
var bnt_close = w.add("button", undefined, undefined, {name: "bnt_close"});
bnt_close.text = "Close";
bnt_close.onClick = function(){w.close()};
w.show();
} ian
... View more
‎Feb 08, 2020
08:53 AM
Ah... Just tried my own code with Layer Sets and it Failed 😞
... View more
‎Feb 08, 2020
08:35 AM
1 Upvote
Thank You This also seems to work having read a bit deeper into the Scripting Manual try {
app.activeDocument.activeLayer = app.activeDocument.artLayers.getByName("Master Layer");
}
catch (e) {
alert("Not Found");
} Guess its just a personal Preference as to which way to do it
... View more
‎Feb 08, 2020
08:00 AM
knowing that there is at least one would probably be sufficient
... View more
‎Feb 08, 2020
07:43 AM
Can someone help me with a script which will search all layers in Active Documnet for a specific name and if found make that the active Layer or Return an Alert if not found. Thanks Ian
... View more
‎Feb 07, 2020
11:55 AM
I an using a script to increase the canvas size by 211 pixels on the right The function is called from a button click. Button Click $("#btn_Canvas_Size").click(function () {
csInterface.evalScript('Canvas_Bigger()');
}); Function Called from Button function Canvas_Bigger() {
var srcDoc = app.activeDocument;
// get original width and height
var w = srcDoc.width.value;
var h = srcDoc.height.value;
// Increase canvas size + 211 pixels to the right
// with the anchor in the top left
srcDoc.resizeCanvas(w +211, h, AnchorPosition.TOPLEFT);
} Question: I am trying to figure out how to prevent the function from firing on multiple clicks of the button. I only want the canvas to be resized the once. Any suggestions please Ian
... View more
‎May 10, 2019
12:54 AM
Ive noticed that when doing something like... alert("Your message here..."); in Windows, the alert box shows Script Alert as the title but Mac doesn't Is there anyway to replace the Script Alert with something else or is it just a Windows thing?
... View more
‎May 08, 2019
08:00 AM
Scenario: In Photoshop.jsx, I place all my code for which I want photoshop to perform For example: I have a function that performs the zoom in and zoom out commands Zoom In: function zoomin(){ var d = new ActionDescriptor(); var r = new ActionReference(); r.putEnumerated(stringIDToTypeID("menuItemClass"), stringIDToTypeID("menuItemType"), stringIDToTypeID("zoomIn")); d.putReference(stringIDToTypeID("null"), r); executeAction(stringIDToTypeID("select"), d, DialogModes.NO); } Zoom Out: function zoomout(){ var d = new ActionDescriptor(); var r = new ActionReference(); r.putEnumerated(stringIDToTypeID("menuItemClass"), stringIDToTypeID("menuItemType"), stringIDToTypeID("zoomOut")); d.putReference(stringIDToTypeID("null"), r); executeAction(stringIDToTypeID("select"), d, DialogModes.NO); } HTML Form: On the index.html, I have 2 buttons each with its own id #btn_zoomin and #btn_zoomout Main.js In the Main.js file, I call the respective function in the photoshop.jsx file like this... //Zoom In $("#btn_zoomin").click(function () { csInterface.evalScript('zoomin()'); }); //Zoom Out $("#btn_zoomin").click(function () { csInterface.evalScript('zoomout()'); }); Question: I would like to replace the 2 buttons on the index.html to a single Toggle-Switch but how can I get the Toggle-Switch to call the function(s) in the Photoshop.jsx file. Any example code would be really appreciated. Ian
... View more
‎May 06, 2019
02:41 PM
Interesting, I never actually thought about that but you maybe right.
... View more
‎May 06, 2019
11:41 AM
Scenario A: Extend the canvas of a photograph at the bottom by 90 pixels Make a selection of the extended area and draw a gradient from black to white Now go to Image - Trim and choose Result: Nothing happens and I cannot understand why? Scenario B: Do the same as above but this time just fill it with a solid color. Result: It works as I would expect, the image goes back to how it was when it started. Ian
... View more
‎May 03, 2019
02:15 PM
This is what I have in ExtendScript This is my channels
... View more
‎May 03, 2019
11:41 AM
I am trying to cycle through the channels and delete a channel with a given name of Lights This is the code but for some reason I just cannot get it to work. function deleteLights (){ for (var i = 1; i <= 5; i++) try { activeDocument.channels.getByName("Lights"+i).remove(); } catch(e) {} } can anyone see if I have missed something Ian
... View more
‎Apr 09, 2019
03:50 AM
Thank you very much I was close but not close enough
... View more
‎Apr 09, 2019
02:56 AM
I am trying to loop through all the channels looking for a specific name of MyChannel If MyChannel is not found then display an alert ("MyChannel Not Found") From reading the Scripting guide, I think I need to be using app.activeDocument.activeChannels.getByName("MyChannel" but just not quite sure how put all this into a function Any help would be appreciated. Ian
... View more
‎Apr 08, 2019
11:55 PM
1 Upvote
In main.js I put this at the top function loadJSX(fileName) { var csInterface = new CSInterface(); var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION) + "/jsx/"; csInterface.evalScript('$.evalFile("' + extensionRoot + fileName + '")'); } And then call the function like this. loadJSX("my-file.jsx");
... View more
‎Apr 08, 2019
09:35 AM
I am trying to figure out how to write a function for Undo and Redo which takes me back or forward one step. This code by r-bin​ works but it undo's all the history state if (activeDocument.activeHistoryState.snapshot) { var d = new ActionDescriptor(); var r = new ActionReference(); r.putEnumerated(stringIDToTypeID("historyState"), stringIDToTypeID("ordinal"), stringIDToTypeID("last")); d.putReference(stringIDToTypeID("null"), r); executeAction(stringIDToTypeID("select"), d, DialogModes.NO); } else { var d = new ActionDescriptor(); var r = new ActionReference(); r.putIndex(stringIDToTypeID("snapshotClass"), 1); d.putReference(stringIDToTypeID("null"), r); executeAction(stringIDToTypeID("select"), d, DialogModes.NO); } Ian
... View more
‎Apr 05, 2019
09:56 AM
I cannot figure out how to get my extension panel to change its color based on what the user selects in Photoshop Preferences Theme Color. In the CSInterface.js file, I see the following but I just cannot work out what to do with it /** * User can add this event listener to handle native application theme color changes. * Callback function gives extensions ability to fine-tune their theme color after the * global theme color has been changed. * The callback function should be like below: * * @Example * // event is a CSEvent object, but user can ignore it. * function OnAppThemeColorChanged(event) * { * // Should get a latest HostEnvironment object from application. * var skinInfo = JSON.parse(window.__adobe_cep__.getHostEnvironment()).appSkinInfo; * // Gets the style information such as color info from the skinInfo, * // and redraw all UI controls of your extension according to the style info. * } */ Any help would be really appreciated Ian
... View more
‎Apr 01, 2019
02:24 AM
I tried the script you linked to written by r-bin and it seems to work very good. I also tried the script by SuperMerlin ( the one which sits in the help menu) but it never seems to display the log. Do you know if this is compatible with the latest version of Photoshop and Mac
... View more
‎Apr 01, 2019
01:56 AM
Thank You, Works perfect
... View more