Copy link to clipboard
Copied
Is there a way to write a script that will assign a hotkey to a keyboard shortcut whereby pressing it will type out a common word or sentence. For instance, in my ad agency we use the phrase "Selected Vtys.," on nearly every item advertised, but rather than spell it out we'd like to be able to simply press Ctrl + (a letter) to write out the entire phrase.
A short script will insert any phrase you want:
try{
app.selection[0].contents = "my phrase";
}
catch(e){}
Save that as a script, and assign any shortcut you want to it...
Copy link to clipboard
Copied
A short script will insert any phrase you want:
try{
app.selection[0].contents = "my phrase";
}
catch(e){}
Save that as a script, and assign any shortcut you want to it...
Copy link to clipboard
Copied
Thank you! I knew it must be something simple. I'm not super fluent in coding so I wasn't exactly sure what codes to input but that code worked! Thanks a lot TAW and everyone!
Copy link to clipboard
Copied
Hey TAW,
Is there any code to force the Cursor to the end of the line after this text is entered? Much appreciated.
Copy link to clipboard
Copied
jamesb64534871 wrote
Hey TAW,
Is there any code to force the Cursor to the end of the line after this text is entered? Much appreciated.
This should do it:
try{
app.selection[0].insertionPoints[-1].select();
app.selection[0].contents = "my phrase";
}
catch(e){}
Ariel
Copy link to clipboard
Copied
Hi James,
what can be done is a list of phrases.
Imagine a two-column table:
In the first column goes the short form in the second column goes the corresponding long form.
A script could know the text file holding the pairs of phrases. One pair of phrases is divided by a unique string. Not a tab character, because you could need a tab as part of a short formed or long formed phrase. Maybe the divider could be something like that: $§$. Something you'd never type or use as a short form phrase.
If you are pressing a KBSC the script will start.
It will look up the text of your current insertion point and would read out the text left from it.
That contents would be analyzed and searched in the text file. If found the long form right from the $§$ would replace the short form of the found phrase.
The script would be an ordinary ExtendScript script file available in your Scripts panel of your InDesign.
As soon it is installed it is available for defining a KBSC for executing it.
So yes, that could be done.
Regards,
Uwe
Copy link to clipboard
Copied
Hi!
This can be done directly in InDesign! Sample: I type "wx" and a space …
(^/)
Copy link to clipboard
Copied
Hi Obi-wan,
yes. I know that are some system tools around that can contribute some strings.
Also automatic text correction comes to my mind with exception lists…
All built in with InDesign. But someone has to maintain and install the lists.
But what is speaking for a script then?
One could implement logics, if else clauses you cannot build with exception lists.
Regards,
Uwe
Copy link to clipboard
Copied
Uwe,
Play with "auto-correction" is so simple! Just need to modify the .xml file with a text editor!
I've just typed:
"uw" + "space" + "carriage-return" + "aw" + "space" + "carriage-return" + "ow" + "space" + "carriage-return"
The company "Geek" could do it and finally send all this .xml file! …
Cool!
(^/)
Copy link to clipboard
Copied
Hi Obi,
I just tried this trick but it's not working.
I've added:
<wordpair misspelled="transtibial" corrected="trans-tibial"/>
<wordpair misspelled="transfemoral" corrected="trans-femoral"/>
I restart InDesign but it doesn't recognise the spelling.
Autocorrect in on, I can check by typing "about" and it changes to "about".
Do you have any ideas?
Copy link to clipboard
Copied
Nevermind, I had the xml as a shortcut on my desktop and for some reason it wasn't updating the original.
Copy link to clipboard
Copied
Maybe I'm wrong but the true problem with the use of a script is that you'll need to "manually" associate a shortcut to it to play it quickly! … and I'm not sure you can't do it automatically!
Good luck if scripts dozens on computers dozens!
(^/)
Copy link to clipboard
Copied
I have noticed that the xml autocorrect doesn't recognise spaces in between misspelled words.
For example:
It changes water-proof to waterproof
but won't change
water proof to waterproof.
Here's the xml:
<wordpair misspelled="water proof" corrected="waterproof"/>
<wordpair misspelled="water-proof" corrected="waterproof"/>
Copy link to clipboard
Copied
Hi Jake,
I did not use the autocorrect feature before, so thank you for this finding.
Hm. And how about special characters of other sort?
Could be a white space character expressed as something like an HTML entity?
  => en space
  => em space
  => thin space
=> non breaking space
Or something like that for a simple blank?

Perhaps also this?

But if that would work,
we also have to care for special characters like:
& # ; etc.pp.
Regards,
Uwe
// EDIT:
The forum software converted my entity for a non breaking space to an actual non-breaking-space.
Copy link to clipboard
Copied
Hi Laubender,
I've done a few tests and nothing seems to preserve the whitespace.
I imagine it's something to do with the InDesign XML parser or the XSLT.
If you find anything I'd be interested