0

Hello gayz,
i have a written a screen saver App in C# & WPF, everything is done, the only thing is to exit the screen saver when the mouse move event get fired.

if i write:

private void Window_MouseMove(object sender, MouseEventargs e)
{
    this.Close();
}

the screen saver doesn't starts at all. therefor:
i need the to get the mouseposition bevor the mousemove event fired, and then check if the mouse was moved more than 20 pixel, than exit the App.
how do i get the MousePosition.
Thanks for any help.

2
Contributors
2
Replies
23
Views
3 Years
Discussion Span
Last Post by grarhakim
1

This should do the trick:

private void  Window_MouseMove(object sender, MouseEventArgs e)
{
    Point P = e.GetPosition(this);
}
0

hi ddanbe and thanks for your reply.
i want the mouse position at App start, for example at App start mousepos1 = (150,600) than it will look like this.

    private void Window_MouseMove(object sender, MouseEventArgs e)
    {
        Point P = e.GetPosition(this);
        if(mousepose1.X >= P.X + 20 || mousepos1.Y >= P.Y + 20)
        {
            this.Close()
        }
    }

i have tried to capture the mousepos at Window_Loaded event but it gives me always (0,0).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.