Skip to main content
September 13, 2010
Question

how to? : Get selected file(s)' path from outside of Bridge

  • September 13, 2010
  • 1 reply
  • 716 views

Hi,

i know there exists some scripts which can be run in Photoshop for example (inside CS) and get the selected files inside bridge.

but i want to write a program (let say with Delphi, or .Net or ....) and i need to get the list of the file(s) which are selected in Bridge, so i don't think that i can use those existing scripts since my programs is running outside of the CS world.

does some one know a how ?!

Thanks,

This topic has been closed for replies.

1 reply

Paul Riggott
Inspiring
September 13, 2010

It's a bit crude but it should return a comma delimited filelist....


using System;
using System.Collections;
using ps = Photoshop;

namespace getBridgeFiles
{
    class Program
    {
        static void Main(string[] args)
        {
            ps.ApplicationClass app = new ps.ApplicationClass();
            String Code = "var fileList;"+
"if ( BridgeTalk.isRunning( 'bridge' ) ) {"+
"var bt = new BridgeTalk();"+
"bt.target = 'bridge';"+
"bt.body = 'var theFiles = photoshop.getBridgeFileListForAutomateCommand();theFiles.toSource();';"+
"bt.onResult = function( inBT ) { fileList = eval( inBT.body ); }"+
"bt.onError = function( inBT ) { fileList = new Array(); }"+
"bt.send(8);"+
"bt.pump();"+
"var timeOutAt = ( new Date() ).getTime() + 5000;"+
"var currentTime = ( new Date() ).getTime();"+
"while ( ( currentTime < timeOutAt ) && ( undefined == fileList ) ) {"+
"bt.pump();"+
"$.sleep( 100 );"+
"currentTime = ( new Date() ).getTime();"+
"}}"+
"if ( undefined == fileList ) {"+
"fileList = new Array();}"+
"fileList = decodeURI(fileList.toString());";
            String RC =  app.DoJavaScript(Code, null, null);
            ArrayList list = new ArrayList();
            list.AddRange(RC.Split(new char[] { ',' }));
            for (int index = 0; index < list.Count; index++){
                Console.WriteLine(list[index]);
        }
            Console.ReadLine();
     
        }
    }
}