1
$\begingroup$
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.

enter image description here (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:

enter image description here

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

Well, maybe fits now?

$\endgroup$
  • $\begingroup$ Your code works fine for me. It creates the new notebook just at the mouse current position. I am on Windows 8.1 $\endgroup$ – SuTron Apr 16 '15 at 8:25
  • $\begingroup$ 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. $\endgroup$ – SuTron Apr 16 '15 at 8:32
  • $\begingroup$ 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. $\endgroup$ – SuTron Apr 16 '15 at 8:38
  • $\begingroup$ @SuTron you can kind of get it from CurrentValue["ScreenArea"] but it becomes messy for multiple screens and different layouts. $\endgroup$ – Kuba Apr 16 '15 at 8:45
2
$\begingroup$

I have no reputation to post this only as a comment, but running your code in Debian with Mathematica 10.0.2 creates the notebook with its top left corner exactly at the mouse position (tested with multiple monitors), not shifted as in your image.

$\endgroup$
  • $\begingroup$ Thanks for a feedback. I think it can stay as an answer. This was part of the question. $\endgroup$ – Kuba Apr 16 '15 at 8:24

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.