12 Replies Latest reply on Feb 27, 2016 7:49 AM by Drako1234

    Installing script with default shortcut

    Drako1234

      Hello!

      I would like to make a scripts so when installed (via the folder startup), it automatically set a specific shortcut to run itself. I checked online and the only way I find to set a shortcut for a script is by manually going into Edit > Keyboard shortcuts...

      Does anyone know how could I do this?

       

      Thank you!

        • 1. Re: Installing script with default shortcut
          Salah Fadlabi Level 5

          Edit>keyboard shortcuts>product area>scripts

          • 2. Re: Installing script with default shortcut
            rob day Adobe Community Professional & MVP

            With AppleScript you might be able to listen for a keystroke combination via System Events inside of the startup script, not sure about JS.

            • 3. Re: Installing script with default shortcut
              rob day Adobe Community Professional & MVP

              scripts so when installed (via the folder startup), it automatically set a specific shortcut to run itself

              If you install a script in the Startup folder it will automatically run when ID starts up. If you want it to run on some event like when an object is placed there are a number of events that the startup script can listen for and then run other commands.

              • 4. Re: Installing script with default shortcut
                Laubender Adobe Community Professional & MVP

                Hi Drako,

                Idea, that could be implemented in various ways:

                With a "placeholder" script you install once and apply a shortcut once.

                 

                That "placeholder" script would e.g. start the first available script in a specific folder somewhere on your hard disk.

                If you want a different script to start, simply rename the one present and add a new one to that folder.
                Or rename the special folder and add a new folder with a different script.

                 

                Not tested much, it's the same like starting a script with a double-click from the OS:

                 

                // Code of placeholder script
                // ExtendScript dummy code:
                Folder("yourFolderPathHere"+"/").getFiles("*.jsx")[0].execute();
                

                 

                Or something like that, also not tested much, but should work:

                 

                // Code of placeholder script
                // ExtendScript dummy code:
                app.doScript(Folder("yourFolderPathHere"+"/").getFiles("*.jsx")[0]);
                

                 

                Maybe symbolic links could work as well…
                (But I never worked that way)

                 

                Uwe

                • 5. Re: Installing script with default shortcut
                  Drako1234 Level 1

                  Hi Uwe!,

                  Thank you for your reply. mh, I’m very NOT familiar with this scripting language myself, I just have many scripts made by someone else and I’m trying to find a faster way to run them.

                  The truth is that I know a bit how to program with autohotkey and Im trying to find a way to make autohotkey to run scripts in InDesign. I want to setup my scripts in INDD so they have a specific, very complex, shortcut combination so they can't be run manually by mistake but, when needed, AutoHotkey can run them by sending the specific key combinations.

                   

                  I am not really sure I understood what these two lines you wrote do. I understand that with this I can make a script to run the first available script that is located into a specific folder.

                  I guess the idea is to install a shortcut for script A and have script A run whatever script is in folder B. So if I want to run different scripts i would have to change the file into the folder B and therefore the shortcut that is for script A becomes automatically the shortcut for the script I place in folder B.

                  Like this I could run whatever script with the same shortcut.

                  If this is what you mean is actually not a bad idea however, I could simply assign a shortcut for script A and call it literally "A.jsx". Then if I want to change the script I would simply need to rename an other script "A.jsk" (overwriting the existing one) and it would have the same effect... no?

                  • 6. Re: Installing script with default shortcut
                    rob day Adobe Community Professional & MVP

                    I want to setup my scripts in INDD so they have a specific, very complex, shortcut combination so they can't be run manually by mistake

                    Seems like you should be able to do that via Key Commands. You can set key commands with 4 modifiers like Ctrl+Opt+Shift+Cmd+F10.

                     

                    so when installed (via the folder startup)

                     

                    Also are you sure you want to be storing scripts in the startup scripts folder? When you put them there, they run when ID is launched and don't show in the Scripts panel.

                    • 7. Re: Installing script with default shortcut
                      Drako1234 Level 1

                      I don't see rob day’s answer here (don't know why but whatever...)

                      rob day: So why don't you want to assign key commands to scripts via Keyboard Shortcuts? Wouldn't that be the same as using a third party app like AutoHotkey?


                      Hi rob day. Well, technically the end result that I'm trying to get is the same. The point is that I have over 15 machines and each of these have different people using them. They have their own scripts (on top of the standard about 60 we use daily) and they have they own logons and shortcuts. I basically cannot log on on each computer and setup manually a specific shortcut each of the standard scripts I’m trying to setup.

                      If I press Win Enter in Indesign, I get the quick apply window in which I can as well make the scripts to showup and run fast. The problem is that they this window shows EVERYTHING and it sorts in a very confusing way with path and everything which makes locating different scripts very slow. What I want to do is to make a similar window with autohotkey that would contain only specific scripts (not all) sorted in a specific way. Then I need that once selected, they run the same way they would run if selected with the quick play window. You understand what I mean? The only way I see I can make Autohotkey to run specific scripts in InDesign is by assigning shortcuts to the scripts and making Autohotkey sending specific keys to INDD.

                      At the same time I dont think anyone would be able to remember every combination for all the 60 standard scripts and I dont want to have so many that one can run them by mistake while typing.

                      Does this clarify a bit more what Im trying to do?

                      • 8. Re: Installing script with default shortcut
                        Drako1234 Level 1

                        Actually I think i like this idea! The only problem now is if I would have different extensions... meaning: right now these two lines you sent me would run *.jsx, but what if I want to run a *.vbs?

                        How do I change this line so it does not pick only one extension but it picks either vbs or jsx?

                        app.doScript(Folder("yourFolderPathHere"+"/").getFiles("*.jsx")[0])

                        • 9. Re: Installing script with default shortcut
                          Drako1234 Level 1

                          Drako1234 wrote:

                           

                          Actually I think i like this idea! The only problem now is if I would have different extensions...

                          ...sorry, my last one was following what I wrote to Uwe ...

                          • 10. Re: Installing script with default shortcut
                            Laubender Adobe Community Professional & MVP

                            Hi Drako,

                            I'm on Mac OSX, so I cannot test this with vbs scripts.

                            There are additional arguments (optional) for the app.doScript() method.

                             

                            The first argument will provide the file, that should run, the second one will define the language of the script (optional).

                            For vbs there I found no explicit language entry in the Document Object Model (DOM) documentation of ExtendScript, just one for AppleScript. But you could try the following:

                             

                            // Code of placeholder script named for example: Placeholder.jsx
                            // ExtendScript dummy code: 
                            app.doScript(Folder("yourFolderPathHere"+"/").getFiles("*.vbs")[0] , ScriptLanguage.UNKNOWN);
                            

                             

                            You could get the string for the path when running the following script from the ExtendScript Toolkit app (ESTK).

                            Simply copy this code to the ESTK, run the script, select the folder where you want to place your scripts and collect the output string from the JavaScript Console of the ESTK.

                             

                            // NO DUMMY CODE (ExtendScript)
                            // Invoke the select dialog command for the folder object:
                            var newFolder = Folder.selectDialog("Chose folder");
                            
                            // If you cancel the dialog, the script will exit at this point:
                            if(newFolder === null){exit()};
                            
                            // If you did not cancel the dialog, the path of the selected folder is written to a variable and supplemented with: /
                            var folderPath = newFolder.fsName +"/";
                            
                            //log the result to the console and border the string with opening and closing " that will define a String:
                            $.writeln("\""+folderPath+"\"");
                            exit();
                            

                             

                            Replace "yourFolderPathHere"+"/" in the brackets of Folder() with the string from the console.

                             

                            Example string I created from chosing the Scripts Panel folder of InDesign CC 2015 on my OSX 10.10.3:

                             

                            "/Applications/Adobe InDesign CC 2015/Scripts/Scripts Panel/"
                            

                             

                            Hope, that helps…

                             

                            Uwe

                            • 11. Re: Installing script with default shortcut
                              Drako1234 Level 1

                              Hi Uwe, thank you very much for your codes :-)

                              I tried to use them and then I arrived to the conclusion this system actually does not work for my purposes :-(

                              The scripts I want to run are in different folders spread in a server, several of them are configured to use data from different documents which are located in the same folder where the scripts are.

                              I therefore have to run them from their current location, I can’t make a copy of them (because i dont know which one is referring to what file).

                              Quite some of them were modified over the years and at every modification a copy was made so if I loop for all the scripts I end up with several duplicates and Im back at the beginning of what Im trying to solve: I get a list with all kind of things which does not help at all.

                              Im basically back at the beginning: looks like that the only way to solve this is to modify each script that I need (long and painful job but once done its done, I hope) and assign a specific individual shortcut to it. Then make Autohotkey to simply use the specific shortcut.

                               

                              So the question stays: any idea how to set a script to install a specific shortcut to run itself?

                              • 12. Re: Installing script with default shortcut
                                Drako1234 Level 1

                                Well, right after I posted this last message I figured I could actually simply make a link instead of a copy of the file :-)

                                I tried and it works. It run the script from where it is (obviously :-P).

                                Basically I create a specific shortcut for a file called MASTER.js.lnk (Lets say Shift+Ctrl+Alt+F1) and then I make Autohotkey to replace this file with a link of the script I want to run and then send the keystroke to INDD.

                                Well, I did not manage to get the EXACT ANSWER I wanted but I solved the problem I wanted to solve :-)

                                 

                                Thank you very much for everything Uwe!

                                 

                                Drako