Skip to main content
Inspiring
October 28, 2024
Answered

Another execution glitch

  • October 28, 2024
  • 1 reply
  • 403 views

I'm surprised at the number of glitches that occur when running ExtendScript. Here's another one: 

 

    ...
    app.executeMenuCommand('deselectall');
    alert(doc.selection.length); // not 0

    while (doc.selection.length !== 0) {
        app.executeMenuCommand('deselectall');
    }
    // at this point the app freezes
    alert(doc.selection.length); // not reached
    ...

 

Opinions, advice?
This topic has been closed for replies.
Correct answer Charu Rajput

@andyf65867865 - It is working as expected, but at times the application does not get updated.

Try using the 

app.redraw();

after

 app.executeMenuCommand('deselectall');

like

app.executeMenuCommand('deselectall');
app.redraw();

 

Please note , the redraw is also very slow. Generally we try to minimize dealings with the DOM as much as possible to avoid slow-downs.

1 reply

Charu Rajput
Community Expert
Charu RajputCommunity ExpertCorrect answer
Community Expert
October 28, 2024

@andyf65867865 - It is working as expected, but at times the application does not get updated.

Try using the 

app.redraw();

after

 app.executeMenuCommand('deselectall');

like

app.executeMenuCommand('deselectall');
app.redraw();

 

Please note , the redraw is also very slow. Generally we try to minimize dealings with the DOM as much as possible to avoid slow-downs.

Best regards
Inspiring
October 28, 2024

@Charu Rajput in my example I tried to use redraw() after each `deselectall` and used a test alert inside `while` - and this alert was shown, it turns out that one redraw is not enough