Controlling location (Space) of Dialog boxes

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:

  1. 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.
  2. 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)?

I don’t think you can.

I suggest checking out Dialog Toolkit Plus, from Shane Stanley.

Freeware | Late Night Software

Dialog Toolkit Plus v1.1.3

Dialog Toolkit Plus is an ASObjC-based script library for showing enhanced dialogs. Add multiple text entry fields, checkboxes, popup menus, radio buttons, path controls, extra buttons, secure fields, images, and rules to dialogs. It requires macOS 10.10 or later. (updated July 9, 2022)

Thanks will try the Toolkit.