How to open a file in Photoshop with javascript

Hello!

I want to open a file / an image with a click of a button in the extension in photoshop > > javascript.

Possibly with the relative path for the file extension (must work on several different computers)

I tried several scripts:

===================================================================================

function somename(){


#target photoshop

var fileRef = "C:\\Users\\Username\\Desktop\\scripting\\image.png"     // I tried several differnet syntay about the path >> / \  \\ etc. etc.

var doc = open(fileRef);
}

================  OR  ==================================================================

function somename2(){


#target photoshop

var fileRef = new File( ~/desktop/scripting/image.png )     // I tried several differnet syntay about the path >> / \  \\ etc. etc.

app.open(fileRef)
}

======================================================

I know that these paths are absolute, but > > None of them had up to present work


Any ideas?


PS: im new on this > > please be specific or provide a few examples thanks :-)!

well a little update!
Thanks Davide!

It works > just, I was a little to the beginner to interpret correctly the answer Davide.

So I put these codes in the main.js file in the JS folder:

(function () {
    'use strict';
    var csInterface = new CSInterface();
    function init() {

        themeManager.init();

        $("#something_1").click(function () {
  var csInterface = new CSInterface();
  var extensionPath = csInterface.getSystemPath(SystemPath.EXTENSION);
  var imagePath = extensionPath + "/image/samplepicture.jpg";
  csInterface.evalScript("openFile('" + imagePath + "')");
        });
    }
    init();
}());

And it's the hostscript.jsx inside the JSX file:

function openFile(imagePath) {
app.open(File(imagePath));
}

And the index.html file call it like this:


Very many thanks to all who helped! Take care!

Ben

Tags: Photoshop

Similar Questions

  • Open the file in Photoshop with Lightroom edits no longer works

    I have LR5.3 and PS CS6. Given that I've updated camera Raw, my files opens as Tiff files when I want to edit in Photoshop. Therefore, any changes in LR before will not be retained. I don't see the window saying 'open in PS with Lightroom edits "? Someone had the same problem? In LR preferences, Tiff is accurate as a file to edit in PS format, but it does not work

    Take a look at this thread: http://forums.adobe.com/thread/1385332?tstart=0

    Who helps?

  • How to open the files .dll automatically with Adobe Reader via Firefox?

    Hello

    When I print labels eBay via Firefox, a .dll file is downloaded. This used to automatically open in Adobe Reader, but now it opens as a text document in TextEdit, so I have to manually open Adobe Reader, change the options to display "all files", then find the .dll file and open it.

    When I try to change the default application in the preferences of Firefox, I can't find anything with the content type "dll".

    Is there a way to have Firefox automatically opens files .dll with Adobe Reader?

    Any help would be appreciated, thanks!

    Steve

    Sorry for the delay, but yes, just stop Firefox so that the mimeTypes.rdf file is released.

  • How to open a file with a .wsx extension

    Original title: .wsx extentions?

    How to open a file with a .wsx extension

    Hello

    Where did you get the .wsx files?

    Please use your favorite search engine to find a program that can open the .wsx files.

  • How to open a file with a .bar extension?

    Anyone know how to open a file with the .bar extension. I can't seem to find a way, and I get junk out of the web says that opens the file, but I find myself with toolbars and other things I don't need or want. Any help would be great. Thank you.

    On Sunday, February 12, 2012 21:12:54 + 0000, KevinAmosMDK wrote:

    Anyone know how to open a file with the .bar extension. I can't seem to find a way, and I get junk out of the web says that opens the file, but I find myself with toolbars and other things I don't need or want. Any help would be great. Thank you.

    See http://filext.com/file-extension/bar and note that
    http://FILExt.com/ is a very good place to look for answers to
    questions like this.
    Ken Blake, Microsoft MVP

  • How to open a file with the extension .odg using Vista?

    How to open a file with the extension .odg using Vista?

    Hi Defiant503,

    Thank you for visiting the forums of answers.microsoft.com.

    I did some research and a file ending with .odg is an OpenDocument Document OpenOffice/StarOffice (Ver 2) of graphics by Sun Microsystems, Inc.    This means that in order to open this file, you will need this program to open it.  You will not be able to open this file with Vista.

    I hope this information helps.

    Kavita M
    Microsoft Answers Support Engineer
    Visit the Microsoft Answers Feedback Forum site
    and let us know what you think.

  • How to open the files .fxm and .fxr with fax windows 7 & scan?

    How to open the files .fxm and .fxr with fax windows 7 & scan?  These faxes have been received when I had Windows XP.

    Hello

    A file with FXR and FXM file extensions is a Document received from WinFax.

    You can open the FXR and FXM file by double clicking on it and let your PC decide which default application should open the file.   If no program opens, the FXR and FXM file, then you have probably an installed application that can view and/or edit FXR and FXM files.

    You can use a Notepad or another text editor to open these files.  Number of files is files read-only, which means little matter file extension, a text editor may be able to view the contents of the file properly.  This may or may not be the case with FXR and FXM files, but it's worth a try.

    How a FXR and FXM files:
    There are two ways to try to convert a file to a different file type:

    a. open the FXR file in its default program and choose to save the file open in another file format.

    b. use a softwarefrom online file conversion to convert these files to another file format.

    Note:
    using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

    Thank you

  • How to open zip files that are included with various tutorials?

    How to open zip files that are included with various tutorials?  Everytime I try I get the message, "It seems that the file has been moved or renamed."  I am a total novice with this stuff!  Thanks for your help.

    On Windows? Right-click on the .zip file that you want to unpack (unzip) and click on "Extract all" from the context menu.

  • How to open a file with the extension x3f (sigma)

    How to open a file with the extension x3f (sigma)?

    Doesn't look good: Lightroom / Camera Raw: Sigma SD1 - when Merrill sensors will benefit, please!

  • I'm trying to open an a 810 nikon raw file but does not open. said gross can't camera model. I have re installed nx2 with erroe u43m1d207. How to open raw files?

    I'm tryng to open an a 810 Nikon raw file, but does not open. Said GROSS CAN'T camera MODEL.  I have re installed nx2 with error code u43m1d207. How to open a file.

    You can use the dng converter if update your adobe programs fails.

    Adobe - Adobe Camera Raw and DNG Converter: for Windows: Adobe DNG Converter 8.7

  • MAC OS Yosemite - CS6 - earlier, I did something to where when I open a file in photoshop, is no longer a single window, now it is two storage ones. one for the program itself, and another for the actual file how to return it where it's all

    -At the time, I did something to where when I open a file in photoshop, is no longer a single window, now it is two storage ones. one for the program itself, and another for the actual file how to return it where it's a window without having to be full screen mode? I managed to go a few times like this, but right now it's really annoying me. Help!

    Screen Shot 2015-01-27 at 4.15.04 PM.png

    Just drag the small window up just under the toolbar, you will see the area highlighted, and when you drop the file should anchor.

  • Impossible to open PNG files in Photoshop CS5...?

    I see a lot of threads with this problem, but none of them seem to have an answer.

    For some reason any right now when I try to open a PNG file in Photoshop it goes right down.  I find myself with an endless "hour glass".

    I had all my directories project website on a network share.  As I no longer sharing all these files with an office of people I decided to move all these files to my own local computer project.  Since I did I can't open PNG files in Photoshop.

    Any information on what might have caused this, or more importantly, how to fix this would be greatly appreciated.  Thank you!

    You can open any other file type?  Or are all opened files causing a freeze?

    If the latter, you can try changing your printer to a local device (instead of on the network).

    It could also be that you're clock looking for recently used files on the network (which is really a problem with the network driver code).  Disconnection of the server network can help.

  • I try tom open a gz file and get an error message: Broken pipe error 32: can someone tell me how to open the files of theses and recover what is in them, in layman's terms please.

    I used a program called by Kivisoft to recover my music files on my hard drive. He recovered their property, but they were in the form of a ZIP file with a gz file. But whenever I tried to open the ZIP file, I get an error message saying broken pipe 32 error. There, someone knows how to open these files and recover music on their part could you explain in simple terms that I'm not good with the user base of coding software. Thank you

    Here are some steps for you: http://www.wikihow.com/Extract-a-Gz-File

    You can start by trying utility GUI Tar to unzip the .gz file

  • How to open a program that ends with... .iXL?

    How to open a program that ends with... .iXL?

    You try to open a file with an extension of .ixl?

    This file extension seems to be associated with the Inmagic Inc. software.

    http://FILExt.com/file-extension/IXL

    http://www.Inmagic.com/dbText

    The file may be in XML format, in which case you can open it with Notepad.

    http://www.iSiloX.com/support/manual/IXL/IXL.htm

    http://www.iSilo.com/ may be what you are looking for.

    http://www.iSilo.com/download/iSiloW32.htm

  • System 32 error (0x00000020): "the process cannot access the file because it is being used by another process.". The operation to open the file will fail with error - 1032 (0xfffffbf8(JET_errFileAccessDenied))"

    Original title: svchost (1020)

    Event type: error
    Event source: ESENT
    Event category: general
    Event ID: 490
    Date: 2010-10-19
    Time: 14:51:34
    User: n/a
    Computer: ROB
    Description:
    Svchost (1020) an attempt to open the file "C:\WINDOWS\system32\CatRoot2\{127D0A1D-4EF2-11D1-8608-00C04FC295EE}\catdb" for read / write access failed with the error System 32 (0x00000020): "the process cannot access the file because it is being used by another process.".  The operation to open the file will fail with error - 1032 (0xfffffbf8(JET_errFileAccessDenied)).

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

    Hi Robrw,

    1. when exactly you receive this error?

    2. don't you make changes to the computer before this problem?

    You can try to rename the catroot2 folder and check if it helps.

    Step 1:

    a. Click Start and in run type C:\windows\system32 and click ok

    b. find the Catroot2 folder. Right-click on Catroot2 and rename it to Catroot2.old

    If you are not able to do the normal mode, try to start in safe mode and rename

    Check out the link for more information on starting your computer in SafeMode below:

    http://support.Microsoft.com/kb/315222

    Step 2:

    If you are unable to access the catroot2 folder, and then try to change the permissions on the files and check if it helps.

    See the following article:

    How to capture a file or a folder in Windows XP

    http://support.Microsoft.com/kb/308421

    Step 3:

    You can also try to temporarily disable third-party security software and firewalls and check what is happening.

    Note: Activate the security software after the resolution of the problem.

    Hope this information is useful.

    Jeremy K
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

    If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

Maybe you are looking for

  • Cannot find GAIN

    Can anyone help? I installed logic pro x and I can't find the gain anywhere.

  • Question on the first battery charge on Satellite A110-195 times

    Hello! I just bought an A110-195, and I heard that I have to charge the battery for the first time without operating the computer. If it is true, how much time I have to load it? Thank you!

  • If a .fcpbundle can be rebuilt? Question Archive:

    I have archived a FCPX project last year and I don't think that I did it correctly. It seems that I selected the .fcpbundle file and "has shown the contents of the package" and then copied all the content on my external hard drive for storage. Now I

  • Question about the parameters of the screen double

    Hello I have some problems with my new TV that I want to connect to my laptop. I have a Toshiba Satellite L300D with Windows Vista.The problem I have is for the installation of the settings of the TV screen. I want to share the desktop between both s

  • Windows vista 32-bit service pack 1 (error 80073712)

    I tried to update this service pack 1 and Dungeon receives this error 80073712 I tried the tool for preparation of system update and after that, I was still not able to date.