# Consistency between MousePosition and WindowMargins

MousePosition["ScreenAbsolute"]


absolute position within the complete screen display

WindowMargins


specifies the distances from each edge of the main display screen to each edge of the notebook window.

Those descriptions are not word to word the same but also seem to be so.

My problem is that I have Win7 and my MenuBar at the left side of the screen. MousePosition is counting from the screen edge while WindowMargins are from the MenuBar.

After evaluating

CreateDocument["TEST",
WindowSize -> {500, 100},
WindowMargins -> {{#, Automatic}, {Automatic, #2}} & @@ MousePosition["ScreenAbsolute"]]


I got new notebook slightly shifted. I'd like it's left top corner to appear exactly on mouse position.

(yes, my menu bar is wide :))

Is this the case on Linux too?

I would like to have clean and stable solution so I don't have to think about where my MenuBar is currently positioned.

I have something in mind but it looks ugly.

Edit My idea is to create floating elements from "Frameless" notebooks. The problem is to put them in right position.

I was digging around lately and found out that WRI has no easy fix either. It seems they are doing, what I was about to do, in Find & Replace dialog:

As you can see, menu list alignment depends on where my Windows Manu bar is...

Well, maybe fits now?

• Your code works fine for me. It creates the new notebook just at the mouse current position. I am on Windows 8.1 – SuTron Apr 16 '15 at 8:25
• I have just tied with the MenuBar on the side. The issue is, that the (0, 0) coordinate is considered to be the intersection point (top-left) of the MenuBar and the rest of the screen. – SuTron Apr 16 '15 at 8:32
• if you can get the MenuBar size using Mathematica (I don't know how to do that) and adjust the mouse position values accordingly,(otherwise doing it in C++ .dll) that should work. – SuTron Apr 16 '15 at 8:38
• @SuTron you can kind of get it from CurrentValue["ScreenArea"] but it becomes messy for multiple screens and different layouts. – Kuba Apr 16 '15 at 8:45