Hi All,
I am using the Listener.log file's Output to create a Automation Plugin Which open a document(Just Like File-%26gt;Open Menu). But I am Providing the file name in the openFile function which I have created based on listener.log file.
sPSActionControl-%26gt;Play(%26amp;result, eventOpen, desc, plugInDialogSilent);
But the problem is When I use the above code in openFile function. It does nothing. But an error is returned on this line.
When I use the Code below
sPSActionControl-%26gt;Play(%26amp;result, eventOpen, desc, plugInDialogDisplay);
It opens a File open Dialog Box to select a file and then open that document which I have selected in the dialog box and Plugin is working very fine.
But I don't want to open the 'File open Dialog box' and Instead my file whose name I have already supplied in the function Should be Open.
Does anyone have any idea about that?
Thanks and Regards,
Sunil Kumar
Regarding eventOpen
There a two points you have to regard here: sPSAction-Play(...) tells Photoshop to invoke an action (in your case eventOpen), the desc variable contains the parameters for that action and the last variable
(plugInDialogSilent/plugInDialogPlay) tells Photoshop if it should show a dialog or not when invoking the action (in this case: a file-open dialog). Now, you either show a ''select file'' dialog in which case you don't have to fill the desc variable or you have to fill the desc variable with the file-name using ''sPSActionDescriptor-%26gt;PutAlias(...)'' as shown in the code below:
(You can also fill the desc and show a dialog in which case the file-name in desc is ignored (at least I think so))
SPErr OpenFile(char * filepath)
{
SPErr error = kSPNoError;
Handle tempAlias = NULL;
PIActionDescriptor result = NULL;
PIActionDescriptor desc = NULL;
//Handle aliasValue = NULL;
#if Macintosh
FullPathToAlias(filepath, tempAlias);
#else
size_t size = strlen(filepath);
tempAlias = sPSHandle-%26gt;New(size+1);
if (tempAlias != NULL)
{
GlobalLock(tempAlias);
strncpy(*tempAlias, filepath, strlen(filepath)+1);
GlobalUnlock(tempAlias);
}
#endif
error = sPSActionDescriptor-%26gt;Make(%26amp;desc);
if (error) goto returnError;
error = sPSActionDescriptor-%26gt;PutAlias(desc, keyNull, tempAlias);
if (error) goto returnError;
error = sPSActionControl-%26gt;Play(%26amp;result, eventOpen, desc, plugInDialogSilent);
Regarding eventOpen
Hi Marc,
Thanks a lot for your help. ? I was using the similar code what you have provided but it was not working.
Now I find the problem. I was passing the wrong path in the string(i.e ''C:\Test.jpg'').
The Correct path is (''C:\\Test.jpg'')
Thanks once again
Regards,
Sunil Kumar
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment