Applescript within Javascript
Hi all, have a question that hopefully will be easy for someone but is beyond my reach at present.
Below is part of a script I am building and it "should" (but doesn't)
// Select the text within a frame labled "Odd Page Header" in the Layers Pallette, then run the Function
app.documents.item(0).pageItems.itemByName("Odd Page Header").texts.everyItem().select(); app.doScript(reFlow)
// Select the text within a frame labled "Even Page Header" in the Layers Pallette, then run the Function
app.documents.item(0).pageItems.itemByName("Even Page Header").texts.everyItem().select(); app.doScript(reFlow)
// The Function: Normally would run a keyboard shortcut to reflow the text but has been changed to just type an "r" for testing
function reFlow () {app.doScript('tell application "System Events" to keystroke "r" ', ScriptLanguage.APPLESCRIPT_LANGUAGE)}
// Deselect
// app.select(null);
The problem is, instead it runs the function twice on the "Even Page Header" box (inserting "rr") and if I uncomment the "Deselect" command it doesn't work at all.
I can see that the app.doScript has to be last to work but have no idea why or how to get around it so it works for each text frame selected.
Have to thank Trevor for helping me on the original app.doScript to get a keystroke but expanding on it for this purpose I have hit a few problems.
Any help would be appreciated, Brendan
