Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // script.name = openAiFilesMaximized.jsx;
- // script.description = This Script fixes the bug that opens the Illustrator window in a "resized" state when opening files by double-clicking on them;
- // script.requirements = Illustrator MUST be MAXIMIZED and all documents need to be closed or saved before running;
- // script.parent = CarlosCanto // 03/15/2013;
- // script.elegant = false;
- // Usage: save or close all open documents and make sure the Illustrator window is MAXIMIZED before running.
- // Note: the script won't actually "maximize" the window, it will merely resize the window to its Maximum.
- #target Illustrator
- if (goAhead()) {
- if (allFilesSaved ())
- restartIllustrator ();
- else alert('Save and/or close all documents and try again');
- }
- else alert('Script terminated by user');
- function goAhead() {
- var title = 'Open Ai Files "Maximized" - \u00A9 2013 Carlos Canto';
- var msg1 = 'This Script fixes the bug that opens the Illustrator window \nin a "resized" state when opening files by double-clicking on them.';
- msg1 += '\n\n1. Illustrator MUST be MAXIMIZED (otherwise the trick will not work) \n2. This Script will need to restart Illustrator.\n\nDo you want to continue?';
- var cont = Window.confirm (msg1, false, title);
- return cont
- }
- function allFilesSaved() {
- var docCount = app.documents.length;
- if (docCount>0) {
- for (i=0; i<docCount; i++) {
- if (!app.documents[i].saved) return false;
- }
- }
- return true;
- }
- function restartIllustrator () {
- var scr = $.screens[0];
- var r = scr.right; // get max width
- var b = scr.bottom; // get max height
- app.preferences.setIntegerPreference ("layout/0/FrameWindow/r",r); // right
- app.preferences.setIntegerPreference ("layout/0/FrameWindow/b",b); // bottom
- buildMsg ();
- app.quit();
- }
- function buildMsg () {
- var bt = new BridgeTalk;
- bt.target = "estoolkit";
- var msg = launchIllustrator + '\rlaunchIllustrator();';
- bt.body = msg;
- bt.send();
- }
- function launchIllustrator () {
- while (BridgeTalk.isRunning('illustrator')) {
- $.sleep(2000);
- }
- $.sleep(2500);
- BridgeTalk.launch('illustrator');
- app.quit();
- }
Advertisement
Add Comment
Please, Sign In to add comment