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

Opening a document from a different application

Engaged ,
Jul 25, 2017 Jul 25, 2017

Copy link to clipboard

Copied

Originally I wrote a C++ SDK plugin that would contain a external function that would open a document, the problem is I'm unable to pass or get the Photoshop memory address (Application) from a .dll for me to use sSPBasic suite, to open a document.

So I am looking for a way to do it with JS, I just need to open a document from C# OpenDocumentInPhotoshop("FilePath"). But I have a few questions, I have not used Javascript too much, so I don't know the limitations.

1. Would I be able to invoke a Open document function from C# either with command line or some other pipe?

2. Does PS treat scripts like plugins? Do they have to be triggered or can they be fired off anytime?

3. Does this sound possible?

TOPICS
Actions and scripting

Views

949

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

Guide , Jul 25, 2017 Jul 25, 2017

I haven't done much with c# but...

Basics  C sharp:-

dynamic app = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.Application"));

app.Load(@"D:/pictures/fileName.jpg");

This is late binding so will select the latest version of Photoshop.

Yes you should be able to pass the file path via args.

Votes

Translate

Translate
Adobe
Guide ,
Jul 25, 2017 Jul 25, 2017

Copy link to clipboard

Copied

I haven't done much with c# but...

Basics  C sharp:-

dynamic app = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.Application"));

app.Load(@"D:/pictures/fileName.jpg");

This is late binding so will select the latest version of Photoshop.

Yes you should be able to pass the file path via args.

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
Engaged ,
Jul 25, 2017 Jul 25, 2017

Copy link to clipboard

Copied

SuperMerlin, I spent 6 hours trying to pipe this in with c++ and all it took was you. Man I owe you a beer, thank you so much! Take care!!!

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
Engaged ,
Jul 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

SuperMerlin​ I have a follow up question for you, how did you end up getting the COM from Photoshop, was there documents on it?

Thanks again!

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
Guide ,
Jul 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

LATEST

I,am not sure what you are asking here, using "Late Binding" dosen't use COM in the normal way, it is more akin to JavaScript so there is no auto completing of code and No Interop DLL is required.

It also only selects the latest version.

I.E:-

if (app.Documents.Count == 0) return;

MessageBox.Show(app.ActiveDocument.ActiveLayer.Name);

You can use script listen code with some slight modifcations ...

MessageBox.Show(isVis().ToString());

/// <summary>

        /// returns if active Layer is visible

        /// </summary>

        /// <returns></returns>

        static Boolean isVis()

        {

            dynamic app = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.Application"));

            ps.ActionReference ref1 = new Photoshop.ActionReference();

            ref1.PutEnumerated(app.CharIDToTypeID("Lyr "), app.CharIDToTypeID("Ordn"), app.CharIDToTypeID("Trgt"));

            return app.ExecuteActionGet(ref1).GetBoolean(app.CharIDToTypeID("Vsbl"));

        }

Sorry if I have got it totally wrong.

Edit:- I have a couple of helper files to help with conversion from scriptListner to COM format or Late Binding format.

Wikisend: free file sharing service

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