3

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.

Thanks!

enter image description here

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
Jerry
  • 2,459
  • 9
  • 15

2 Answers2

5

Does:

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.

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
  • 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? – Kuba Nov 07 '18 at 07:51
  • 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. – Jerry Nov 07 '18 at 08:21
1

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]}*)

SetOptions[$FrontEnd, 
 NotebookEventActions :> {{"MenuCommand", "New"} :> 
    CreateDocument[]}]

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.

Jerry
  • 2,459
  • 9
  • 15