I'm trying to figure out how to write keyboard and mouse inputs to the port. In my code, every 15 milliseconds the mouse coordinates are written to the port.
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
writeToPort(new Point(e.X, e.Y));
}
public void writeToPort(Point coordinates)
{
if (watch.ElapsedMilliseconds > 15)
{
watch = Stopwatch.StartNew();
port.Write(String.Format("X{0}Y{1}",
(coordinates.X / (Size.Width / 180)),
(coordinates.Y / (Size.Height / 180))));
Then I had an int called Key that changed it's value depending on what key you pressed (w changed it's value to 1, a changed it's value to 2, s changed it's value to 3, d changed it's value to 4) and I tried to write that to the port at well.
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
writeToPort(new Point(e.X, e.Y));
}
public void writeToPort(Point coordinates)
{
if (watch.ElapsedMilliseconds > 15)
{
watch = Stopwatch.StartNew();
port.Write(String.Format("X{0}Y{1}K{2}",
(coordinates.X / (Size.Width / 180)),
(coordinates.Y / (Size.Height / 180)),
Key));
What I found though, was that when the mouse was staying still, the key wasn't being written to the port.
How can I make the Key be written to the port when I press it?