Get Mouse Position

How do i get the mouse x and y position for the entire screen? Not just the unity window.

hi, use

Input.mousePosition

it will return Vector2

Hi emadgh. I need the position on the monitor. Not the unity window.

mmmm… let me think…
.
.
.
I think I dont know :cry:

1 Like

yea so you would have to use an external “bot” program. I wont tell you how or where to get them. However they are run as standalone applications. I am almost positive that you can not get the mouse location on the whole screen from within Unity without integrating one of these bot programs.

EDIT: This might help for those of you that are code savy: Processing Global Mouse and Keyboard Hooks in C# - CodeProject

I managed to use the user32.dll but there are a lot of problems with it. It only works with windows standalone builds and it uses monitor position not unity window position. Thats a problem because i can’t get GetCursorPos working. Can only get SetCursorPos working.

[DllImport("user32.dll")]
    public static extern int SetCursorPos(int x, int y);

Does anyone know how to make GetCursorPos() work? I think it requires the System.Drawing.dll because of its use of the Point class.

Found this quote via google…

Hi .
I have same problem .

please help me … :slight_smile:

thanks