Skip to main content
Inspiring
July 20, 2017
Question

setting sSPBasic without passing (message) from photoshop entry point?

  • July 20, 2017
  • 5 replies
  • 2479 views

I am calling a method to my .8LI from an external application 'Managed' but I am a little stuck with setting the [SPBasicSuite sSPBasic]

    SPMessageData* basicMessage = (SPMessageData*)message;

    sSPBasic = basicMessage->basic;

I need to acquire the suite from PIUSuites 'To open a document' but I can't seem to set it externally (as a SPMessageData object),

  1. Is there a global suite that I can access?
  2. Anything I can do to fire the plugin entry to get the (message)?
  3. A way I can get SPMessage data without passing it in the plugin entry?
  4. Any other option to acquire or open the document without using: sSPBasic->AcquireSuite(suiteName,  suiteVersion,  (const void**)&suite);

It's Windows Automation plugin written in c++.

My current plugin entry:

extern "C" __declspec(dllexport) void __cdecl  PluginMain(char* caller, char* selector, void* message){

}

Thanks!

This topic has been closed for replies.

5 replies

Legend
July 24, 2017

Ok, if your code is running within Photoshop there is a chance to use the APIs. But a plug-in cannot just decide to run. It has to be event driven BY PHOTOSHOP. What you need to do, I believe is write a Photoshop plug-in, install it as a Photoshop plug-in, and get events to it using Photoshop. Yes, it may be possible to split this logic into other DLLs but this just makes the job harder. I know little more than this so I will bow out to see if anyone knows any more tricks.

Tom Ruark
Inspiring
July 31, 2017

More context on what exactly you are trying to do would help.

-- During Startup you should be able to save off the value in a global.

If you are trying to "do something in Photoshop via automation plug-in" when my external app decides to do something...

-- You should use OLE Automation on windows or AppleScript on mac to control Photoshop form an external application.

i73Author
Inspiring
July 31, 2017

More context on what exactly you are trying to do would help.

-- During Startup you should be able to save off the value in a global.

If you are trying to "do something in Photoshop via automation plug-in" when my external app decides to do something...

-- You should use OLE Automation on windows or AppleScript on mac to control Photoshop form an external application.

Thanks Tom for the reply, quick follow up:

1. Does this global get assigned to the application (Can I just set up the suit at start up and call it from an external app)? And if so, off the top of your head do you know the function to set a global in PS C++? I won't be using it for this example, I just need to set a global to tell PS that it has a open file from an external app so I can call back to the app a refresh when the user saves a file.

2. I'm trying OLE in c# currently, late binding seems to work perfectly:

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

         var doc = app.Open("D:\\a.psd");

Though I would like access to the library; So I am trying to use the Photoshop COM Assembly, when I do I get an error (No interface supported):

   

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

    var doc = app.Open("My Image Path);

So I'm trying to register "TypeLibrary.tlb" manually but it's not working for me:

Thanks for any help!

Legend
July 24, 2017

That wouldn't help. The API calls must be made from the plug-in, running in Photoshop's address space. Furthermore a plug-in doesn't just "run" when it wants to, it has callbacks triggered by external events. Conceptually, this is a complete non starter. Maybe you can do this with scripting.

i73Author
Inspiring
July 24, 2017

Sorry you may be missing some information, my Automation plugin is running with a Photoshop process (I start Photoshop first, then I load in and enter 'DllMain' at PS startup [I was referring to that when I was talking about storing a global, I assume I can store an application global], then I call my external function from my external app ~ "it has callbacks triggered by external events") So when you say a plugin doesn't just run I understand that, I'm starting the PS process first and loading in all the memory.

I will give it a try with .js but with this new information you still think I'm unable to do it from the plugin?

Thanks again!

i73Author
Inspiring
July 24, 2017

Darn I was really hoping there was a way around using sSPBasic,

Is there a global object I can store in PhotoShops application itself on start up, and just point back to it? Can you think of anything I can do here?

Thanks for your help!!

Legend
July 24, 2017

Yes, I mean only Photoshop can do this. Photoshop plug-ins load in the Photoshop address space. External applications do not. A plug-in is a plug-in and only that; the plug-in API is not a set of useful APIs you can use in your external application.

Legend
July 23, 2017

Photoshop plug-ins are not external. Writing a plugin of another kind will not make a working Photoshop plug-in.

i73Author
Inspiring
July 24, 2017

Sorry I am a little confused, are you saying I am unable to set: sSPBasic without Photoshop sending the message (SPMessageData, object)on plugin main?

I'm able to access functions from an external application so I am not sure what you mean by 'Photoshop plug-ins are not external' I'm not writing a plugin of another kind, my goal is to somehow access an sSPBasic object (Without photoshops plugin main firing, the sSPBasic message) is this possible?

If not is there another way I can open a document without setting a SPMessageData object?