• Advertisement

Archived

This topic is now archived and is closed to further replies.

How to get mouse position in C#

This topic is 2489 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a way to get the mouse position in C# when the mouse is outside of a form or control? I want to get the mouse position anywhere on the screen, but dont like DirectInput because it only gives changes in mouse position, not the actual position. Thanks Possibility

Share this post


Link to post
Share on other sites
Advertisement
I may be wrong, but I believe both of these will work:

System.Windows.Forms.Control.MousePosition

or System.Windows.Forms.Cursor.Position

will give you the moust cursor position in screen coordinates.

[edited by - ares32585 on March 7, 2004 7:23:25 PM]

Share this post


Link to post
Share on other sites
Hi , [font="arial, sans-serif"][size="2"][i]I am working[/i] on [i]a project[/i] for[/size][/font] tracking mouvement of mouse in the screen
ii am a beginner in c sharp , ii'll be so grateful if someone can help me even with link of code or some thing else.plzzzz
Ps: sorry for my english[img]http://public.gamedev.net/public/style_emoticons/default/sad.gif[/img]

Share this post


Link to post
Share on other sites
heeeyy, hellooo , i m still here [img]http://public.gamedev.net/public/style_emoticons/default/sad.gif[/img]

Share this post


Link to post
Share on other sites
Here is how I caught the mouse x,y from MouseEventArgs

[code]

private void pictureBox_View_MouseDown(object sender, MouseEventArgs e)
{
...
int x, y;
x = e.X;
y = e.Y;
...
...
}
[/code]

Otherwise, if you need it on something other than an event, look into ares32585's response. I have never done such a thing myself.

Share this post


Link to post
Share on other sites
thx [img]http://public.gamedev.net/public/style_emoticons/default/rolleyes.gif[/img]

Share this post


Link to post
Share on other sites

  • Advertisement