left menu mob button

New Video on YouTube:

You will never find time for anything. If you want time, you must make it. (Charles Buxton)


Danko Josic
(05.06.2020 1:08):

Thank you. Great help.

(Common Formatting of Several Tables)

(28.04.2020 20:50):

Это замечательно! Огромное спасибо за скрипт!!!

(Split Text By Paragraphs)

(25.04.2020 16:41):

Михаил, приветствую! Пример того, как создаются выпадающие списки стилей, можно посмотреть, например, в скрипте: eugenyus.rudtp.ru/ru/applyParStyleWithNextStyle Строки 3-19 - создание массивов, окна и выпадающего списка в этом окне; строка 30 - получение доступа к выбранному пользователем стилю после того, как была нажата кнопка выполнения. Там происходит обращение к абзацным стилям. Чтобы организовать список символьных стилей, нужно просто заменить везде в этих строках paragraph на character.

(Quick formatting)

Only The Necessary Information

(series of articles):

Quick formatting

Each of us, sooner or later, will receive a text for layout, which cannot be formatted with the available automation tools. For example, if the author of the text does not know how to use different underlining types in MS Word, you will have to manually apply several character styles, one by one or interspersed.

If, at the same time, you prefer the "high-speed" style of work, imagine what emotions are waiting for you from the algorithm: "double click on the word —> mouse over the style —> mouse click —> look at the source text —> find the word in the layout —> double click on the word —> repeat cycle". How many times will you miss the right style? And if you use "hotkeys" — how many times will you have to take off your right hand from the mouse and not miss (in the "high-speed" mode) the right key? And, as we remember, there are dozens of words, if not hundreds of them...

And, if it is impossible to fully automate the formatting process in this case, is it possible to at least reduce the number of actions to a minimum by teaching a program to assign the desired formatting right at the moment of the selection of the desired text? That is, it would be great if the layout designer would select a text by double-clicking, and the text would be formatted by itself, getting the desired style. Then one would need to just click the right words with the mouse and do nothing else, and this is a huge saving of time and nerves of the layout designer.

It is this problem that the algorithm presented below solves.

#targetengine "quickformatting"
var myEventHandler = function(ev){
		//Here the required action is performed. For example, I have assigned a character style to a set of consecutively allocated characters:
		app.activeDocument.selection[0].appliedCharacterStyle = "Desired Character Style"; 
		w.text = "It's working!";
	catch(e){w.text = "It doesn't work!";}

var w = new Window("palette");
var butStart = w.add("button",undefined,"Start"); //This button will enable / disable event listener.
var started = false; //Using this variable, we determine whether event listener is enabled or not.
butStart.onClick = function(){
    if (!started){
        //If event listener disabled, enable
        app.activeDocument.addEventListener('afterSelectionChanged', myEventHandler);
        butStart.text = "Stop"; //Switch button text
        //If event listener is on, turn off
        app.activeDocument.removeEventListener('afterSelectionChanged', myEventHandler);
        butStart.text = "Start"; //Switch button text
    started = !started; //When we click on the button, reassign the variable
w.onClose = function(){
	if (started){
		app.activeDocument.removeEventListener('afterSelectionChanged', myEventHandler);

The start/stop button is responsible for the behavior of the program at the moment when the text selection occurs — whether the selected text will receive the formatting specified in the script or not. And from the videos below, I hope, it is clear that the capabilities of such a code allow one to use it not only to apply a character style, but also for more complex tasks.

Updated on 16.12.2015. A conditional action has been added to the script, which stops the script if the user closes the script window, having forgotten to press Stop before that. These lines should be placed before the last line: w.show();

w.onClose = function(){
	if (started){
		app.activeDocument.removeEventListener('afterSelectionChanged', myEventHandler);