Get mouse position in Editor based on screen coordinates

I have a button in an editor window, and when I click the button, I’d like to open a new editor window on top of that at the position of the button I clicked on. As far as I know the Event.current.mousePosition gives me the mouse position relative to the editor window I’m in and also relative to the guilayout. So, similar to GetLastRect, if I’m inside of a beginhorizontal or two, then the mouse position isn’t even going to be relative to my current editor window.

My question is, how can I either get the mouse position or the button position in absolute coordinates ( not relative to the guilayout ) so that I can open the editor window at the location of the button I clicked.

If neither of these questions have answers, does anyone have any ideas for me to accomplish this problem a different way? Maybe finding the location of the button or mouse cursor isn’t the way to solve this.

Please note that this is in the editor, needs to be able to run on mac and windows, and must work on multi monitor displays.

Edit 2:

Did some tests and this line of code seems to work for me, even when I have two monitors.

GUIUtility.GUIToScreenPoint(Event.current.mousePosition)

Original:
First thing that I can think of is that you could calculate the offset of the button rect from the window rectangle.

If you know the relative offset within the window, you should be able to calculate the screen position from the window’s X & Y coordinates.

Edit:
This might also help -

I tried out GUIUtility.GUIToScreenPoint but could never get it to work right.

This is what ended up doing it for me:

var actualScreenPosition = new Vector2(
    Event.current.mousePosition.x,
      
    // the Y position is flipped, so we have to account for that
    // we also have to account for parts above the "Scene" window
    Screen.height - (Event.current.mousePosition.y + 25)
);

This actually came from here:

https://forum.unity.com/threads/getting-mouse-coordinates-in-editor-mode.41585/