5 Replies Latest reply on Mar 26, 2010 10:51 AM by Peter Kahrel

    Get current Library

    kumar1981 Level 1

      Hi,

       

         Is there anyway to find active/current library?

       

      For Example, app.activeDocument,app.activeWindow returns current one. Likewise app.activeLibrary ? is it correct?

       

       

      I have more libraries in my library panel.What is the code I have to use to find active Library?

       

       

       

      Please suggest me.

       

       

      Regards

      kumar

        • 1. Re: Get current Library
          Harbs. Level 6

          I think it's app.libraries[0] (but I'm not sure about that).

           

          Harbs

          • 2. Re: Get current Library
            Peter Kahrel Adobe Community Professional & MVP

            There is a propert app.activeBook, but it doesn't work very well. I use the following functions for that. They display a list of books from which you pick one:

             

             

            myBook = get_book ();

            function get_book ()
                {
                switch (app.books.length)
                    {
                    case 0: alert ("Please open a book."); exit ();
                    case 1: return app.books[0].name;
                    default: return pick_book ();
                    }
                }


            function pick_book ()
                {
                var w = new Window ("dialog", "Select a book");
                w.alignChildren = "right";
                var g = w.add ("group");
                    var list = g.add ("listbox", undefined, app.books.everyItem().name);
                    list.minimumSize.width = 250;
                    list.selection = 0;
                var b = w.add ("group");
                    b.add ("button", undefined, "OK", {name: "ok"})
                    b.add ("button", undefined, "Cancel", {name: "cancel"})
                if (w.show () == 1)
                    return list.selection.text;
                else
                    exit ();
                }

             

            Use this line to call the functions:

             

            myBook = get_books ();

             

            Peter

            • 3. Re: Get current Library
              Steven.. Level 3

              pkahrel wrote:

               

              There is a propert app.activeBook, but it doesn't work very well. I use the following functions for that. They display a list of books from which you pick one:

               


               

              He's looking for Active library.

               

              About active book, there is a confirmed bug with adobe. see more discussion at http://forums.adobe.com/message/2587771

              • 4. Re: Get current Library
                [Jongware] Most Valuable Participant

                Was I actually dreaming, thinking I answered this yesterday?

                 

                It was the same answer as you guys gave, so I actually have nothing to add, except for the OP:

                 

                Just like with Books, you can have more than one library open, and just like with Books, you can drag each library out of the panel, so the entire concept of an "active" one is invalidated.

                • 5. Re: Get current Library
                  Peter Kahrel Adobe Community Professional & MVP

                  > He's looking for Active library.

                   

                  I too was dreaming apparently. But anyway, you can script picking a library in the same way as picking a book, I guess.

                   

                  P.