Skip to main content
danielw42205661
Known Participant
October 23, 2021
Question

Is it possible to create a script that emulates key combinations?

  • October 23, 2021
  • 6 replies
  • 1825 views

Is it possible to write scripts that emulate a key combination? 

 

As an exmaple, could you write a script that exectues "shift+right key" combination on the keyboard so if a word is highlighted, it would add an extra highlighted character to the word when activating the script.

 

Sometimes I feel like it would be easier if I just had my indesign scripts panel open and double clicking on a script instead of doing a shortcut key combination. Thanks!

This topic has been closed for replies.

6 replies

Colin Flashman
Community Expert
Community Expert
October 24, 2021

There are a few ways that I can use to activate my scripts:

  1. Use quick apply (Command/Ctrl + Enter) - brings up a dialog where - by typing the name of the command you want, it can be called upon. There is the ability to add scripts to this by clicking the down arrow to the left of the text field and select Include Scripts (s:);
  2. Apply keyboard shortcuts to scripts as outlined by Rob Day in an earlier post;
  3. Make the script accessible via the contextual menu so that it can be called upon by right-clicking and navigating to the script in the menu - this requires some scripting knowledge.
  4. Make the script accessible via the main menu as outlined by Marc Autret over at Indiscripts: https://www.indiscripts.com/post/2010/02/how-to-create-your-own-indesign-menus
  5. If you have tons of scripts and don't want to have to scroll all day in the scripts panel, Peter Kahrel has a script launcher that can filter out scripts to make them easier to find: https://creativepro.com/files/kahrel/indesign/runscript.html
  6. Hot-key a script using an additional button on a mouse, tablet or other navigating device;
  7. If you have an old smartphone that is gathering dust, turn it into a device similar to Elgato's Streamdeck by using software called Touch Portal... or if you have access to Elgato's Streamdeck, consider using the buttons on the streamdeck.

I've written some of these tips in more description over here: https://colecandoo.com/2020/08/02/small-tips-to-save-big-time/

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
Inspiring
October 24, 2021

Cool article (small tips...) 🙂

that's exactly how I think about work. Too bad you're a Mac user :), AutoHotKey is an incredible thing. for example radial menu:

https://youtu.be/t99qBlasVmM

Colin Flashman
Community Expert
Community Expert
October 27, 2021

Just stumbled onto this github that carries on from my fourth point in my post: https://github.com/grefel/addScriptFolderToMenu/ - it's in German but view it through Chrome with translation on, should be fine.

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
Inspiring
October 24, 2021

AutoHotKey

Send,^+r ;it will send ctrl+shift +r in any program you want

 

 

James Gifford—NitroPress
Legend
October 23, 2021

Not a direct solution, but I've worn out three Logitech macro keyboards in the last few years. Being able to automate actions way out at the user interface solves/enables a lot of things that even sophisticated scripting can't.

danielw42205661
Known Participant
October 23, 2021

Yeah I bought a Motospeed numpad that I use for exactly that. Unfortunately I've already assigned shortcuts/scripts to all the keys on that now. Maybe it's time to buy a second one. 

rob day
Community Expert
Community Expert
October 23, 2021

As an exmaple, could you write a script that exectues "shift+right key" combination on the keyboard

 

Re-read your post, are you looking for a script that will add a character to the text selection so you can avoid the key command? It is scriptable, something like this:

 

 

var a = 1;
try {
    var s = app.documents[0].selection[0];
    app.documents[0].select(s.parent.characters.itemByRange(s.characters[0].index, s.characters[s.length-1].index+a));
}catch(e) {}; 

 

danielw42205661
Known Participant
October 23, 2021

Yeah, that was just one example. I was hoping it would be possible so I could edit the script to do any number of key combinations, without having to know how to write javascript. I knew it probably wasn't possible unfortuantely. Thank you very much for that script though. I will definitely be using it a lot. For some reason if you highlight a word that has a period at the end, it doesnt highlight the period as well, so this script will come in handy for that.

rob day
Community Expert
Community Expert
October 23, 2021

You can apply key commands to your scripts via Edit>Keyboard Shortcuts>Product Area>Scripts, or simply leave your Scripts panel open.

 

 

Community Expert
October 23, 2021

You can have your Scripts panel open - Window>Utilities>Scripts

And dock the script panel with your other panels.

I have mine docked to the left beside the Tools. 

You can then Save your workspace.

https://helpx.adobe.com/indesign/using/workspace-basics.html