Below code can set the window size of current notebook

SetOptions[EvaluationNotebook[], WindowSize -> Scaled[0.8], 
 WindowMargins -> {{0, 0}, {0, 0}}]

However, I found that if the window is maximized, this line of code does not work. See

enter image description here

How to resize maximized window programmetically?

  • $\begingroup$ If you use "F12" to get "FullScreen" then it works. However, if you use the button at right top, then it is Windows that does the drawing and your code does not work. $\endgroup$ Jan 3, 2022 at 8:14
  • $\begingroup$ @DanielHuber Ok~ but I think pressing "F12" is not an ordinary operation :) $\endgroup$
    – matheorem
    Jan 3, 2022 at 9:15
  • $\begingroup$ "F12" is equivalent to the MMA menu "Window"->"FullScreen" $\endgroup$ Jan 3, 2022 at 9:21
  • $\begingroup$ @DanielHuber Yeah, I know. I mean at least for me, I do not use "FullScreen" mode at all. $\endgroup$
    – matheorem
    Jan 3, 2022 at 16:26

1 Answer 1


For some reason, switching the window frame type first seems to work. (In 12.1)

myFrame = CurrentValue[WindowFrame];
SetOptions[EvaluationNotebook[], WindowFrame -> "Normal"]
SetOptions[EvaluationNotebook[], WindowFrame -> "Generic"]
SetOptions[EvaluationNotebook[], WindowFrame -> myFrame, 
 WindowMargins -> {{0, Automatic}, {Automatic, 0}}, 
 WindowSize -> Scaled[0.8]]
  • 1
    $\begingroup$ Great! This works. Thank you so much. $\endgroup$
    – matheorem
    Jan 5, 2022 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.