I wrote an AppleScript control app which directs an application (Numbers) to open and manipulate 2 documents, with each document window in separate desktops/displays:
- Primary working document. This is where the operator (me) can scroll through the document and cycle through multiple sheets within that document as needed. So this document window is in the main display.
- Status board document. This shows a collection of data which is periodically updated. It is put in a separate (extended) display to be either projected or shared on Zoom. So its nature is mostly static and for display purposes only.
The script prompts the user for regular inputs, such as text strings and yes/no questions. These are all by using display dialog.
The issue is where display dialog windows appear. When I have the script open in the Script Editor, the dialog windows always appear where that file is open, i.e. the main display.
But if I close the script file, or Quit the Script Editor altogether (and run the script from the systemwide script menu), the display dialog windows will appear mostly in the wrong display, that is the extended display, obstructing the status board (which is being projected or shared). So the operator must grab the dialog window and drag it back to the main window. However, the dialog window sometimes appears in the main display (where it belongs), but more often appears in the wrong place. Most confusingly, this behavior seems completely random.
I’ve tried placing activate statements in various places, with no effect.
How can I control the dialog window to always be in a designated Desktop/Space (when run with script file closed)?