I've wanted to create a program that moves the cursor by pressing the W
,A
,S
,D
keys. I created a form because it was difficult to put the Keyboard.IsKeyDown(Key.W)
in the script.
This is the code I have so far:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Input;
namespace keyboardMouse
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void rdnbtnMove_CheckedChanged(object sender, EventArgs e)
{
if (Keyboard.IsKeyDown(Key.W))
{
Cursor.Position = new System.Drawing.Point(
Cursor.Position.Y + 5);
}
}
}
}
However, it throws this error
Member 'Cursor.Position' cannot be accessed with an instance reference; qualify it with a type name instead
How can I fix this? Any help is appreciated.