Can't see the cursor's movement programmatically
c#, console-application, mouse-cursor
Solution
I really don't see any problem, here is a test code, it works for me (win7_64):
class Program
{
[StructLayout(LayoutKind.Sequential)]
public struct MousePoint
{
public int X;
public int Y;
}
[DllImport("user32.dll", EntryPoint = "SetCursorPos")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetCursorPos(int X, int Y);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetCursorPos(out MousePoint lpMousePoint);
static void Main(string[] args)
{
ConsoleKey key;
MousePoint point;
while ((key = Console.ReadKey(true).Key) != ConsoleKey.Escape)
{
GetCursorPos(out point);
if (key == ConsoleKey.LeftArrow)
point.X -= 10;
if (key == ConsoleKey.RightArrow)
point.X += 10;
if (key == ConsoleKey.UpArrow)
point.Y -= 10;
if (key == ConsoleKey.DownArrow)
point.Y += 10;
SetCursorPos(point.X, point.Y);
}
}
}
Credits goes to @Keith answer.
It does this
Problem
OK there, after really doing some research and trying a lot of examples- Moving mouse cursor programmatically How to move mouse cursor using C#? Getting mouse position in c# Control the mouse cursor using C# http://www.blackwasp.co.uk/MoveMousePointer.aspx and becomes frustrated I'm asking you guys for help. I'm trying to move the cursor, programmatically (in console application, c#). --> As I read the altered location it seems fine - but I can't actually see the difference. The cursor's image staying the same place... I want to actually see the cursor at it's altered location Thanks Edit 2: Thank you all guys for helping, currently I'm just keep working without seeing the cursor moving anywhere... so its hard to get any feedback about it's locations (just guessing).