How to config the preference so that when a new Notebook frontend be created or opened then the Notebook be moved and aligned to screen's TopLeft with the screen's Height automatically?

On Windows OS platform there is WindowsKey + LeftArrow key-pressing combination to make it one another manually.


enter image description here



CurrentValue[$FrontEndSession,WindowMargins] = {{0, Automatic}, {Automatic,0}};
CurrentValue[$FrontEndSession,WindowSize] = {Automatic, Scaled[1]};

nb = CreateDocument[];

do what you want? The above settings are only active during the current Mathematica session. If you want to make it permanent, use $FrontEnd instead.

| improve this answer | |
  • $\begingroup$ It does not work with Ctrl+N. The solution in 100414 does not work with CreateDocument though. What do you think about moving this answer there and marking this topic as a duplicate? $\endgroup$ – Kuba Nov 7 '18 at 7:51
  • $\begingroup$ Thanks but the script runs in $FrontEndSession case WindowsMargins should be assigned with {{-10,Automatic},{Automatic,0}}, I don't understand why the value be negtive . When $FrontEnd is applied, It doesnot work on UI operations. $\endgroup$ – Jerry Nov 7 '18 at 8:21

Thanks to @Carl Woll's scripts, the following scripts work.

CurrentValue[$FrontEnd,WindowMargins] = {{-10, Automatic}, {Automatic,0}};(*{{0,Automatic},{Automatic,0}}*)
CurrentValue[$FrontEnd,WindowSize] = {Scaled[0.5], Scaled[1.01]};(*{Automatic,Scaled[1]}*)

 NotebookEventActions :> {{"MenuCommand", "New"} :> 

The MenuCommand is defined in MenuSetup.tr file located in installtion directory. However, I'm not sure about one of the WindowsMargins value-elments be negative. The FrontEnd might get screen values in chaos in multi-monitors case.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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