Copy link to clipboard
Copied
Is it possible to control, where the new dialogue window/alert of a custom script will appear on the screen when triggered? I have a new 4k monitor + 2nd smaller one. I use illustrator in the 4k monitor. All the alerts appear off-centered of the screen and the scripts that have a dialogue window open in the other monitor.
Is there a way to control, where the new windows appear? Moving them by hand does not work or do anything.
I can somehow control it when changing the Main display option in windows 11 settings, but they still appear in random places on the screen. Added sample picture for reference.
Hi @martink15467522 I think this might be a tricky problem because I don't think ScriptUI has a very sophisticated understanding of multiple monitors. One option is to just store the position that the user moves it to, and re-instate it next time. We can use Illustrators preferences for this. Here is a script showing this approach.
- Mark
/**
* @file Store ScriptUI Window Location Example.js
*
* (For Adobe Illustrator only.)
*
* @author m1b
* @version 2025-12-05
*/
(function () {
...
Copy link to clipboard
Copied
Hi @martink15467522 I think this might be a tricky problem because I don't think ScriptUI has a very sophisticated understanding of multiple monitors. One option is to just store the position that the user moves it to, and re-instate it next time. We can use Illustrators preferences for this. Here is a script showing this approach.
- Mark
/**
* @file Store ScriptUI Window Location Example.js
*
* (For Adobe Illustrator only.)
*
* @author m1b
* @version 2025-12-05
*/
(function () {
const DEFAULT_X = 200;
const DEFAULT_Y = 200;
const NO_PREFERENCE_VALUE = 1861879264;
var w = new Window('dialog { text:"Window position example" }');
var textGroup = w.add('Group { margins:[10,10,10,10] }');
textGroup.add('StaticText { text:"The quick brown fox jumps over the lazy dog." }');
var okayButton = w.add('Button { text: "Done", alignment:["right","top"], properties:{ name:"ok" } }');
okayButton.onClick = function () {
// store the window location in preferences
app.preferences.setIntegerPreference('windowLocationLeft', w.location[0]);
app.preferences.setIntegerPreference('windowLocationTop', w.location[1]);
w.close(1);
};
// read the window location from preferences
var windowX = app.preferences.getIntegerPreference('windowLocationLeft');
var windowY = app.preferences.getIntegerPreference('windowLocationTop');
if (NO_PREFERENCE_VALUE === windowX)
windowX = DEFAULT_X;
if (NO_PREFERENCE_VALUE === windowY)
windowY = DEFAULT_Y;
w.location = [windowX, windowY];
var result = w.show();
if (2 === result)
// user cancelled
return;
})();
Copy link to clipboard
Copied
Thanks! This works.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more