Question
ExtendScript VBScriptの連携
「新規ページ参照...」メニューアクションを使って索引を作ろうと考えました。
「新規相互参照」ダイアログが表示されている間はScriptが止まる様なので
外部にVBScriptを作っておいてそれを呼び出しています。
外部のVBScriptでキー操作をおこない、ダイアログの操作をしているのですが「読み」の部分が二重に入力されてしまいます。
解決方法がありますでしょうか?
外部のVBScript(ディスクトップに「KeyOperations.vbs」として存在(キーボード操作を行いますので注意)
Dim MyShell
Set MyShell= WScript.CreateObject("WScript.Shell")
WScript.Sleep 1000
MyShell.SendKeys "%s" 'キー操作 ALT + S
WScript.Sleep 500
MyShell.SendKeys "^v" 'キー操作 CTRL + V
WScript.Sleep 500
MyShell.SendKeys "%l" 'キー操作 ALT + L
WScript.Sleep 500
MyShell.SendKeys "{ENTER}" 'キー操作 ENTER
Set MyShell = Nothing
ExtendScript
var indexArray = ["猫", "犬"];
var readingArray = ["ねこ", "いぬ"];
app.documents.add();
app.activeDocument.textFramePreferences.properties = {
autoSizingType : AutoSizingTypeEnum.HEIGHT_AND_WIDTH,
autoSizingReferencePoint : AutoSizingReferenceEnum.TOP_LEFT_POINT,
useNoLineBreaksForAutoSizing : true
}
for(var i = 0; i < indexArray.length; i++){
var myTextFrame = app.activeDocument.pages.firstItem().textFrames.add();
for(var j = 0; j < 10; j++){
myTextFrame.parentStory.contents += indexArray[i];
}
}
var myTextFrameForCopy = app.activeDocument.pages.firstItem().textFrames.add();
app.findTextPreferences = NothingEnum.NOTHING;
for(var i = 0; i < indexArray.length; i++){
myTextFrameForCopy.parentStory.contents = readingArray[i];
myTextFrameForCopy.texts.firstItem().select(SelectionOptions.REPLACE_WITH);
app.copy();
app.findTextPreferences.findWhat = indexArray[i];
var findResultArray = app.activeDocument.findText();
findResultArray[0].select(SelectionOptions.REPLACE_WITH);
app.doScript('Dim MyShell\r' +
'Set MyShell = CreateObject("WScript.Shell")\r' +
'MyShell.Run MyShell.SpecialFolders("Desktop") & "\\KeyOperations.vbs"\r' +
'Set MyShell = Nothing'
,ScriptLanguage.VISUAL_BASIC);
app.menuActions.item("新規ページ参照...").invoke();
}