• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Executing .jsx Javascript file from .net c#

Explorer ,
Feb 02, 2017 Feb 02, 2017

Copy link to clipboard

Copied

I have a ASP .NET c# website and I want to call a JavaScript file (with extension .jsx)  to create a new image file from Photoshop to display.

No issues or problems with the JavaScript file.

The problem is finding the code in c# to call the JavaScript file from .NET C# (version 4.6) with the correct parameters.

Hoping somebody has solved this before can answer.

Stephen

TOPICS
Actions and scripting

Views

3.1K

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

correct answers 1 Correct answer

Explorer , Feb 03, 2017 Feb 03, 2017

Finally found a working Solution for .NET C# to use .JavaScript .JSX files.

Add Reference from COM object for Photoshop

Add to top of Code page;

using Photoshop;

Code required is;

            string cFile = HttpContext.Current.Server.MapPath("~/Test Action.jsx");

            Photoshop.ApplicationClass app = new Photoshop.ApplicationClass();

            string[] aArguments= new string[0];  // as no Parameters

            app.DoJavaScriptFile(cFile,aArguments,1) ;  // not sure why it is 1 as final paramet

...

Votes

Translate

Translate
Adobe
Enthusiast ,
Feb 02, 2017 Feb 02, 2017

Copy link to clipboard

Copied

If your JSX file has

#target Photoshop

on first line in script, then doubleclick on this file can run script in Photoshop (by default).

Doubleclick could be replaced with runing JSX filem from command line. No arguments required.

Votes

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 ,
Feb 02, 2017 Feb 02, 2017

Copy link to clipboard

Copied

Thanks for your reply.

But the code is embedded in a website and the user does not have access to the Desktop, so your proposed solution cannot work

The code required is linked to the action of a button click and is in .NET C# and it requires to execute the JavaScript .Jsx file.

Stephen.

Votes

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
Enthusiast ,
Feb 02, 2017 Feb 02, 2017

Copy link to clipboard

Copied

If PS and JSX are both server-side then it should work.

You could run "c:\your\path\action.jsx" from C# .NET

Votes

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 ,
Feb 02, 2017 Feb 02, 2017

Copy link to clipboard

Copied

Yes thanks, both files/applications are server side.

But I'm looking for the .NET C# syntax of executing the action.JSX file as it does not operate as a usual JavaScript file

as .JSX is Extended version.

Stephen

Votes

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
Enthusiast ,
Feb 02, 2017 Feb 02, 2017

Copy link to clipboard

Copied

I mean like this: .net - Run an exe from C# code - Stack Overflow But you will run jsx instead exe.

If you have properly set #target in jsx.

JSX has nothing todo with <script></script> in HTML. (except panels inside Photoshop)

Votes

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 ,
Feb 03, 2017 Feb 03, 2017

Copy link to clipboard

Copied

Thanks for link to Stack Flow .Net C# code

However this code (adjusted for actual file names ) creates error as follows;

Win 32 Exception was Caught

The specified executable is not a valid application for this OS platform.

So cannot in .NET C# treat .Jsx as Script or Exe - so how can I execute the JavaScript .Jsx file?

Stephen

Votes

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 ,
Feb 03, 2017 Feb 03, 2017

Copy link to clipboard

Copied

LATEST

Finally found a working Solution for .NET C# to use .JavaScript .JSX files.

Add Reference from COM object for Photoshop

Add to top of Code page;

using Photoshop;

Code required is;

            string cFile = HttpContext.Current.Server.MapPath("~/Test Action.jsx");

            Photoshop.ApplicationClass app = new Photoshop.ApplicationClass();

            string[] aArguments= new string[0];  // as no Parameters

            app.DoJavaScriptFile(cFile,aArguments,1) ;  // not sure why it is 1 as final parameter could not find documentation on options.

            app.Quit();

Thanks for contributions.

Hope this solution helps, somebody else.

Stephen

Votes

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