Hey, i have kinda silly problem, i need to set Point Pos as mouse current position in one if statement and in another statement move mouse cursor to setted position. First i need assign global Point variable but then Cursor moves to assigned variable and i don’t want that happens.
Part of source:
protected override void WndProc(ref Message m)
{
Point Pos = new Point(0, 0);
if (m.Msg == 0x0312)
{
int id = m.WParam.ToInt32();
if (id == 0)
{
Pos.X = MousePosition.X;
Pos.Y = MousePosition.Y;
}
if (id == 1)
{
Cursor.Position = (Pos);
}
}
base.WndProc(ref m);
}
If you intend to capture the mouse position and restore it later then you have to make the Pos variable a field of your class instead of a local variable of the method. Like this: