Cronos

Illustrator Open Ai Files Maximized Script

Mar 15th, 2013
1,300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // script.name = openAiFilesMaximized.jsx;
  2. // script.description = This Script fixes the bug that opens the Illustrator window in a "resized" state when opening files by double-clicking on them;
  3. // script.requirements = Illustrator MUST be MAXIMIZED and all documents need to be closed or saved before running;
  4. // script.parent = CarlosCanto // 03/15/2013;
  5. // script.elegant = false;
  6.  
  7.  
  8. // Usage: save or close all open documents and make sure the Illustrator window is MAXIMIZED before running.
  9.  
  10. // Note: the script won't actually "maximize" the window, it will merely resize the window to its Maximum.
  11.  
  12.  
  13. #target Illustrator
  14.  
  15. if (goAhead()) {
  16.     if (allFilesSaved ())
  17.         restartIllustrator ();
  18.     else alert('Save and/or close all documents and try again');
  19. }
  20. else alert('Script terminated by user');
  21.  
  22. function goAhead() {
  23.     var title = 'Open Ai Files "Maximized" - \u00A9 2013 Carlos Canto';
  24.     var msg1 = 'This Script fixes the bug that opens the Illustrator window \nin a "resized" state when opening files by double-clicking on them.';
  25.     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?';
  26.     var cont = Window.confirm (msg1, false, title);  
  27.     return cont
  28. }
  29.  
  30. function allFilesSaved() {
  31.     var docCount = app.documents.length;
  32.     if (docCount>0) {
  33.         for (i=0; i<docCount; i++) {
  34.             if (!app.documents[i].saved) return false;
  35.         }  
  36.     }
  37.     return true;
  38. }
  39.  
  40. function restartIllustrator () {
  41.     var scr = $.screens[0];
  42.     var r = scr.right; // get max width
  43.     var b = scr.bottom; // get max height
  44.  
  45.     app.preferences.setIntegerPreference ("layout/0/FrameWindow/r",r); // right
  46.     app.preferences.setIntegerPreference ("layout/0/FrameWindow/b",b); // bottom
  47.  
  48.     buildMsg ();
  49.     app.quit();
  50. }
  51.  
  52. function buildMsg () {
  53.     var bt = new BridgeTalk;
  54.     bt.target = "estoolkit";       
  55.     var msg = launchIllustrator + '\rlaunchIllustrator();';
  56.  
  57.     bt.body = msg;
  58.     bt.send(); 
  59. }
  60.  
  61. function launchIllustrator () {
  62.     while (BridgeTalk.isRunning('illustrator')) {    
  63.         $.sleep(2000);
  64.     }
  65.     $.sleep(2500);
  66.     BridgeTalk.launch('illustrator');
  67.     app.quit();
  68. }
Advertisement
Add Comment
Please, Sign In to add comment