0
0

More than 1 year has passed since last update.

InDesign JavaScript 検索結果を一覧を表示

Posted at

検索結果を一覧を表示するスクリプトは、これで良いのかな・・・?

/*
このスクリプトを利用して起こった不具合の責任は取れません。
ご了承下さい。

更新 2021/010/27
*/

// アプリ指定
#target "indesign";

// スクリプト名
var scriptName = "検索結果を一覧を表示";

//スクリプトの動作指定(一つのアンドゥ履歴にする、及び、アンドゥ名)
app.doScript(function () {

    // ダイアログ
    var dialogueFlg = confirm("「検索と置換」の 『正規表現』 での検索の値で検索した結果を表示します。"
    ,"", scriptName);

    // Noの場合
    if (dialogueFlg == false) {

        // 終了
        exit();
    }

    // ドキュメント全体から検索
    grepResultArray = app.activeDocument.findGrep();

    // 検索結果のコンテンツ
    resultContentsArray = [];

    for(var i = 0; i < grepResultArray.length; i++){

        // 結果のコンテンツを収集
        resultContentsArray.push(grepResultArray[i].contents);
    }

    /* 表示 */
    // ダイアログX座標
    var dialogWidthXCoordinates = 0;

    // ダイアログY座標 
    var dialogWidthYCoordinates = 0;

    // ダイアログ幅
    var dialogWidth = (app.activeDocument.layoutWindows[0].bounds[3] - app.activeDocument.layoutWindows[0].bounds[1]) / 2

    // ダイアログ高さ
    var dialogHeight = (app.activeDocument.layoutWindows[0].bounds[2] - app.activeDocument.layoutWindows[0].bounds[0]) / 2

    // 段落スタイル選択用ダイアログ作成
    var textWindow = new Window("dialog", scriptName, [dialogWidthXCoordinates, dialogWidthYCoordinates, dialogWidthXCoordinates + dialogWidth, dialogWidthYCoordinates + dialogHeight]);

    // エディットテキスト追加
    textWindow.add("edittext",[ 20, 20, dialogWidth - 20, dialogHeight - 20],resultContentsArray.join("\r"),{readonly:true,multiline:true});

    // 中央に
    textWindow.center();

    // 表示
    textWindow.show();
    /* ここまで */

//スクリプトの動作指定の続き
}, ScriptLanguage.JAVASCRIPT, [scriptName], UndoModes.ENTIRE_SCRIPT, scriptName);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0