I've made a program were I can control a linux computer (In this case, a raspberry pi) running my Receiver script (Python). So far, I'm able to send nearly all characters, letters and numbers to it. Problem is, the mouse movement. Right now I'm using the NUMPAD to control the mousemovement, but it's slow and it can only move +x or +y, not both.
So I'm wondering if I could somehow freeze my mouse position in the program and when I try to move the mouse, it will send the mouse movement changes. Meaning that if I where to drag the mouse, it would send something like "MOUSE(+10, -4)" in UDP packet. I don't want it to spam the Receiver.py with UDP packets, so I guess a little timer would be nice. I'm mostly wondering about how I would be able to freeze the mouse while it being functioning in the program.
Here is the code I'm using to send numbers, symbols and letters:
if (piCheck.Checked) //As long as this is checked, every letter and mousemovement should be sent.
{
try
{
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
string IpAddress = textBox1.Text;
IPAddress serverAddr = IPAddress.Parse(IpAddress);
IPEndPoint endPoint = new IPEndPoint(serverAddr, _PORT);
byte[] send_buffer = UTF8Encoding.UTF8.GetBytes(e.KeyCode.ToString());
sock.SendTo(send_buffer, endPoint);
textinfo.Text = "It's fine...? Yea it is.";
}
catch (System.FormatException)
{
textinfo.Text = "SENDING ERROR";
}
}
Yes, I have a lot more to the code than that, including Upper keys, CTRL, SHIFT etc..
You probably don't know much about Python, but here is some of the code:
######MOUSE######
elif data == 'NumPad8':
os.system("xte 'mousermove 0 -6'")
elif data == 'NumPad6':
os.system("xte 'mousermove 6 0'")
elif data == 'NumPad5':
os.system("xte 'mousermove 0 6'")
elif data == 'NumPad4':
os.system("xte 'mousermove -6 0'")
elif data == 'NumPad0':
os.system("xte 'mouseclick 1'")
elif data == 'CTRLNumPad0':
os.system("xte 'keydown Control_L' 'mouseclick 1' 'keyup Control_L'")
elif data == 'Insert':
os.system("xte 'keydown Shift_L' 'mouseclick 1' 'keyup Shift_L'")
elif data == 'Decimal':
os.system("xte 'mouseclick 3'")
elif data == 'Subtract':
os.system("xte 'mouseclick 4'")
elif data == 'Add':
os.system("xte 'mouseclick 5'")
It uses the extension Xautomation. (sudo apt-get install xautomation)
Please help.