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.

Recommended Answers

All 2 Replies

This should do the trick:

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

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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.