Избранное »

22.09.2014 – 07:27 | 2 комментария | 27 190 views

Здравствуйте все, кто работает в Индизайне!
Извещаем вас о том, что на youtube.com работает канал «InDesign Мастерская вёрстки». Там уже размещены более 70 видео с полным описанием как работать с программой DoTextOK. Другие интересные темы, касающиеся работы …

Читать полностью »
Работа в InDesign

Хитрости и секреты, приемы работы, уроки

Новая версия!

Особенности новой версии Индизайна

Плагины

Описание плагинов, информация о плагинах для работы с Adobe InDesign

Скрипты

Готовые к использованию скрипты для Adobe InDesign

Скриптинг

Описание языка, приёмов и методов программирования для Adobe InDesign

Home » Скрипты

Cкрипт для запуска скриптов

Добавлено на 14.10.2008 – 23:17Без комментариев | 1 485 views

Peter Kahrel разработал оригинальный скрипт, при помощи которого можно запускать другие скрипты, находящиеся в пользовательской папке скриптов.

Изюминка его в состоит в том, что он ведет историю запусков скриптов, сохраняя первым в списке последний из запускавшихся скриптов.
Задав сочетание «горячих клавиш» на запуск этого скрипта в дальнейшем мы получаем очень удобную систему для работы со скриптами и можем почти не пользоваться стандартной панелью Scripts Индизайна.

//DESCRIPTION: Script launcher with history list
//Peter Kahrel

//change the value to increase/reduce the history list
maxHistory = 14;
scriptNames = [];
scriptDir = app.activeScript.path+’/’;
historyFile = File( scriptDir + ‘runscript-last.txt’ );

//get the scripts listed in the history file and in the script dir
scriptNames = createDropDown( scriptDir );
f = getScript( scriptDir );
updateHistoryList( f.name, histList );
app.doScript( f );

//end ———————————————————————-

function createDropDown( dir )
{
var array = [];
//if the history list does not exist, create it
if( historyFile.exists == false)
{
new File( historyFile);
histList = »
}
else //if it does exist, read it
{
historyFile.open( ‘r’, undefined, undefined);
histList = historyFile.readln();
array = histList.substr(1).split(‘Ј’);
//add a line to divide the history list and tthe rest of the scripts
array.push( ‘————————‘);
historyFile.close();
}
//add the scripts in the script folder
var allScripts = Folder( dir ).getFiles( ‘*.jsx’ );
for( var i = 0; i < allScripts.length; i++ )
array.push( allScripts[i].name );
return array
}

//—————————————————————————

function getScript( dir )
{
dlg = app.dialogs.add( { name : ‘Launch a script’ } );
with( dlg )
with( dialogColumns.add())
with( borderPanels.add())
{
staticTexts.add( {staticLabel : ‘Script:’ } );
with( dialogColumns.add())
{
var script = textEditboxes.add( { minWidth : 200 });
var dropDown = dropdowns.add( {
stringList : scriptNames,
selectedIndex : 0,
minWidth : 200 })
}
}
if( !dlg.show() )
{ dlg.destroy(); exit() };
if( script.editContents != » )
{
var scrName = script.editContents;
//if user didn’t type extension, add it
if( scrName.indexOf( ‘.jsx’ ) < 0)
scrName += ‘.jsx’;
script = File( dir + scrName );
if( !script.exists )
{
alert( ‘Error: ‘ + scrName + ‘ doesn\’t exist’ );
dlg.destroy;
exit()
}
}
else
script = File( dir + scriptNames[dropDown.selectedIndex] );
return script
}

//—————————————————————————

//scripts are separated by Ј (sterling sign). Easier than \r in RE
function updateHistoryList( f, history )
{
f = ‘Ј’ + f;
if( history.indexOf( f ) < 0 )
history = f + history;
else
{
//move the name to the front of the list
history = history.replace( RegExp(‘(.*)(‘ + f + ‘)(.*)’),’$2$1$3′);
//if list is max length, chop off last item
if( history.match(/Ј/g).length > maxHistory )
history = history.match(/^(.*)+Ј.*$/)[1];
}
historyFile.open( ‘w’, undefined, undefined );
historyFile.writeln( history );
historyFile.close()
}


Другие интересные и бесплатные скрипты этого автора вы можете посмотреть и скачать на странице http://www.kahrel.plus.com/indesignscripts.html

Оставить комментарий!

Вы должны быть в системе чтобы оставить комментарий.